problem plotting heatmap for pathways?
0
0
Entering edit mode
6.7 years ago
Sharon ▴ 610

Hi Everyone

Does anyone know how can I fix the genedata function arguments to plot heatmap for my pathways? is not the rownames of keggres and foldchanges is what is needed? And how can i make the ref =control and samples = tumors ?

pdf("pathwayheatmap.pdf")
head(rownames(keggres) )
for (gs in rownames(keggres$greater) ){
outname = gsub(" |:|/", "_", substr(gs, 10, 100))
geneData(genes = kegg.gs[[gs]], exprs =keggres$greater,
heatmap= T, Colv = F, Rowv = F, dendrogram = "none",  scatterplot = T)
}
dev.off()

But the code all is below:

res$entrez <- mapIds(org.Hs.eg.db,
                     keys=row.names(res),
                     column="ENTREZID",
                     keytype="ALIAS",
                     multiVals="first")


foldchanges = res$logFC
names(foldchanges) = res$entrez
#========================================
#---------- Use Kegg and gage to get upregulated and downregulated pathways
#========================================

datakegg.gs)
keggres = gage(foldchanges, gsets =kegg.gs, same.dir =TRUE, compare="unpaired")
lapply(keggres, head)
write.csv(keggres,"keggres.csv")
keggrespathwaysup = data.frame(id=rownames(keggres$greater), keggres$greater) %>%
  tbl_df() %>%
  filter(row_number()<=5) %>%
  .$id %>%
  as.character()
keggrespathwaysdn = data.frame(id=rownames(keggres$less), keggres$less) %>%
  tbl_df() %>%
  filter(row_number()<=5) %>%
  .$id %>%
  as.character()

#---------------------- 
keggresidsup = substr(keggrespathwaysup, start=1, stop=8)
keggresidsup
keggresidsdn = substr(keggrespathwaysdn, start=1, stop=8)

gobpres = gage(foldchanges, gsets=kegg.gs, same.dir =TRUE, compare ="unpaired")

lapply(gobpres, head)
#========================================
#----------------- Define plotting function for applying later
#========================================

plot_pathway = function(pid) pathview(gene.data=foldchanges,gene.idtype="ENTREZID", pathway.id=pid, species="hsa", new.signature=FALSE)
#---------------- plot multiple pathways ups and downs
tmpup = sapply(keggresidsup, function(pid) pathview(gene.data=foldchanges,gene.idtype="ENTREZID", pathway.id=pid, species="hsa"))
tmpdn = sapply(keggresidsdn, function(pid) pathview(gene.data=foldchanges,gene.idtype="ENTREZID", pathway.id=pid, species="hsa"))

#========================================
#--------------PATHWAY HEATMAP STARTS HERE
#========================================
pdf("pathwayheatmap.pdf")
head(rownames(keggres) )
for (gs in rownames(keggres$greater) ){
outname = gsub(" |:|/", "_", substr(gs, 10, 100))
geneData(genes = kegg.gs[[gs]], exprs = keggres$greater,
heatmap= T, Colv = F, Rowv = F, dendrogram = "none",  scatterplot = T)
}
dev.off()
RNA-Seq Pathways Heatmap • 2.8k views
ADD COMMENT
0
Entering edit mode

Hey again Sharon, could you elaborate on what exactly is the issue? - the gene names are not appearing in the figure?

If you run str(keggres), you should see the structure of the object and, through that, see what you need.

ADD REPLY
0
Entering edit mode

Thanks Kevin a lot :) This keggres as printed to a file:

"","greater.p.geomean","greater.stat.mean","greater.p.val","greater.q.val","greater.set.size","greater.exp1","less.p.geomean","less.stat.mean","less.p.val","less.q.val","less.set.size","less.exp1","stats.stat.mean","stats.exp1"
"hsa00534 Glycosaminoglycan biosynthesis - heparan sulfate",0.0310478747746372,1.91067408961101,0.0310478747746372,0.999999904675628,25,0.0310478747746372,9.5324371500611e-08,-5.31872747642397,9.53243715006107e-08,1.52518994400977e-05,170,9.53243715006111e-08,1.91067408961101,1.91067408961101
"hsa04260 Cardiac muscle contraction",0.0531429604749096,1.62792967555232,0.0531429604749096,0.999999904675628,61,0.0531429604749096,2.12844570943935e-07,-5.22307250153027,2.12844570943934e-07,1.70275656755147e-05,110,2.12844570943935e-07,1.62792967555232,1.62792967555232
"hsa04740 Olfactory transduction",0.0739055328200429,1.4605510819635,0.0739055328200429,0.999999904675628,48,0.0739055328200429,5.00123675578046e-07,-5.09479009739885,5.00123675578043e-07,2.66732626974956e-05,79,5.00123675578046e-07,1.4605510819635,1.4605510819635

pathwayheatmap.pdf is empty, when I even open, it says "this document doesn't contain any thing" I think I am playing the genedata parameter incorrectly? I think the problem is here: kegg.gs[[gs]] as I got this: "The number of genes found in exprs is 0 or 1, no need to proceed"

ADD REPLY
0
Entering edit mode

Let me try to take a look later. Sorry, just traveling today!

ADD REPLY
0
Entering edit mode

Take your time Kevin, thanks

ADD REPLY
0
Entering edit mode

That's the keggres$greater object that you have shown, right?

The one thing to be careful about is the encoding of numerical data in these objects. In many scenarios, the numerical data may be encoded as characters an therefore interpreted as factors / categorical variables. Can you check that they are numerical?

ADD REPLY
1
Entering edit mode

I will get back to this Kevin,, thanks so much, just stuck with the github conflict to restore my code :D

ADD REPLY
1
Entering edit mode

What I printed above is keggres. But I found that keggres$greater shows some numbers and characters which could be the issue. Many thanks for this, I think I got a clue what could be wrong now. Will elaborate more if it is not solved. Thanks Kevin so much.

ADD REPLY

Login before adding your answer.

Traffic: 2729 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6