1

I tried to make a basic scatter plot with R using gene expression data.

#import data: 

oldmice <- read.table("oldmice.txt", header = TRUE)
youngmice <- read.table("youngmice.txt", header = TRUE)

Imported data contains: format is the same for both imported data but MGE has different values.

 gene   MGE
Sox17   -6.74193774617653   
Mrpl15  -0.212567471203473  
Lypla1  -0.711251006455475  
and so on.. 

Made basic volcano plot using: youngmice$MGE vs oldmice$MGE

plot(oldmice$MGE, youngmice$MGE, main="old vs young mice!!",
     xlab="oldmice$MGE ", ylab="youngmice$MGE ", pch=19)

My question is how to color "genes" which is in multiple_gene_lists into oldmice$MGE, youngmice$MGE? (which should label the only multiple_gene_list which are in multiple_gene_lists into oldmice$MGE, youngmice$MGE)

Here is my multiple_gene_list

multiple_gene_list <- read.table("multiple_gene_list.txt", header = TRUE)
multiple_gene_list  <- as.vector(multiple_gene_list )

multiple_gene_list contains:

gene
Six6
Arl2
Tmem74B
Rab9B
Rasgef1B
Ccne1
Apln
Spag7
C17Orf59
Krtap4-4

And my goal is to only label multiple_gene_list in oldmice$MGE, youngmice$MGE. I also tried the following code but failed!

with(subset(ASC_oldmice_exprs, ASC_oldmice_exprs$gene %in%  multiple_gene_list$gene), points(ASC_youngmice_exprs$MGE, pch=20, col="red"))

Thank you!

choij
  • 227
  • 1
  • 7
  • Hello and welcome to stackoverflow. It's difficult for us to help you without a reproducible example to work with. Look here: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example for how to make one. – Greg Mar 13 '20 at 20:11

1 Answers1

0

Let's get some data:

multiple_gene_list =structure(list(gene = structure(c(8L, 2L, 10L, 6L, 7L, 4L, 1L, 
9L, 3L, 5L), .Label = c("Apln", "Arl2", "C17Orf59", "Ccne1", 
"Krtap4-4", "Rab9B", "Rasgef1B", "Six6", "Spag7", "Tmem74B"), 
class = "factor")), class = "data.frame", row.names = c(NA, 
-10L))

set.seed(111)

oldmice = data.frame(
gene=c("Six6","Arl2","Tmem74B",letters[1:10]),
MGE=runif(13))

youngmice = data.frame(
gene=c("Six6","Arl2","Tmem74B",letters[1:10]),
MGE=runif(13))

There's 3 overlap, and we define colors like:

COLS = ifelse(oldmice$gene %in%  multiple_gene_list$gene,
"turquoise","orange")

And plot:

plot(oldmice$MGE, youngmice$MGE, main="old vs young mice!!",
     xlab="oldmice$MGE ", ylab="youngmice$MGE ", pch=19,col=COLS)

sel = oldmice$gene %in%  multiple_gene_list$gene
text(x=oldmice$MGE[sel]+0.01,
y=youngmice$MGE[sel]+0.01,
oldmice$gene[sel])

enter image description here

StupidWolf
  • 45,075
  • 17
  • 40
  • 72