Jeez!! THank you very MUCH!!! I will try here right now!
How the best way to verify the up and down regulated genes in a list of DE genes, generated from DEseq?
I have a table of DE genes from each experimental group. And I have a list of genes in each chromosome. I want to look the number of up and down DE genes in this table but in each chromosome.
I thought to use excel, but it turn out to be too much complicated. Can someone expert in R try to help me?
• 6,951 views
•
link
2 answers
This is one way you can do it:
library(reshape2)
library(plyr)
# read table1
table1 <- read.delim('table1.txt',header=T)
table1 <- as.data.frame(t(table1))
table1$ID <- rownames(table1)
table1 <- melt(table1,id.vars = "ID")
# Now we have modified the table1 to look like this
table1
ID variable value
Chromossome.1 V1 ENSMUSG00000101180
Chromossome.2 V1 ENSMUSG00000086670
Chromossome.3 V1 ENSMUSG00000051777
Chromossome.4 V1 ENSMUSG00000095455
Chromossome.5 V1 ENSMUSG00000067321
Chromossome.6 V1 ENSMUSG00000087613
# read table2
table2 <- read.delim('table2.txt')
# specify if a gene is up or down regulated
table2$class <- ifelse(table2$Fold.Change>0,"up","down")
# Table2 looks like this
table2
Gene.ID.s Gene.Name Fold.Change pValue class
ENSMUSG00000101180 xyz 0.400 NA up
ENSMUSG00000086670 abc 0.454 NA up
ENSMUSG00000051777 pqr 0.330 NA up
ENSMUSG00000095455 dlkf 1.550 NA up
ENSMUSG00000067321 dlk 3.222 NA up
ENSMUSG00000087613 dlkf 9.980 NA up
# I added some junk data in table2 to match the Ensembl IDs in table1 and table2
# merge the two tables based on Ensembl IDs
res <- merge(table1,table2,by.x='value',by.y="Gene.ID.s")
# count the number of up and down regulated genes based on chromosomes
res.count <- count(res,vars = c("ID","class"))
# Result
res.count
ID class freq
Chromossome.1 up 1
Chromossome.2 up 1
Chromossome.3 up 1
Chromossome.4 up 1
Chromossome.5 up 1
Chromossome.6 up 1
• 0 views
•
link
It worked like a charm, thank you very much.
But using
table2$Fold.Change = as.numeric(as.character(table2$Fold.Change))
R insert only NA's
I changed to
table2$Fold.Change <- as.character(table2$Fold.Change)
and than worked just fine. I am not sure why but it worked.
Thank you very much!
• 0 views
•
link
Log in to answer this question.
Can you post few lines of both the files so that any body can give you a simple command/script ?
So you have a list of DEGs and a list of Genes per Chromosome and you want to count the number of up and downregulated genes in each chromosome? Can you paste the top 5 lines of each list/file?
komal.rathi exactly. Here is my 2 tables, the first contains the genes of each chromossome, the second, my genes with fold change, when negative the gene is downregulated, and positive up regulated. I must search the gene in the chromossome list, indentify the chromossome number, and mark it as up or down. Can you help me ? =S
I promise help other people when I learn programing.
Can you paste some data that overlaps? For e.g. here the Gene IDs in table1 are not present in table2.