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()
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.Thanks Kevin a lot :) This keggres as printed to a file:
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"Let me try to take a look later. Sorry, just traveling today!
Take your time Kevin, thanks
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?
I will get back to this Kevin,, thanks so much, just stuck with the github conflict to restore my code :D
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.