Open hgb1111 opened 5 years ago
Can you send please send me the source code of the function plotPathHeatmap that you are using? I think I pushed an updated function to github that fixed this issue. I cannot reproduce your error on my end so I need some more information.
Thanks!
Em seg, 18 de fev de 2019 às 14:24, hgb1111 notifications@github.com escreveu:
When I run:
genelist <- c('Hspg2', 'Kdr', 'Plvap', 'Gja4') plottrajectories(cellrouter, '8.9', genelist, rescale = TRUE, columns=1, width=5, height=2, filename='results/dynamics_curve.pdf')
the plottrajectories function runs just fine.
When I try to run plotPathHeatmap with the same genelist:
genelist <- c('Hspg2', 'Kdr', 'Plvap', 'Gja4') plotPathHeatmap(cellrouter, '8.9', genelist, 2, 4, 2, dir = 'results/heatmap.pdf')
I get the error:
Error in
.rowNamesDF<-
(x, value = value) : invalid 'row.names' lengthHow can I make a heatmap with the desired genes?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/edroaldo/cellrouter/issues/20, or mute the thread https://github.com/notifications/unsubscribe-auth/AJqUR1lJgxL1FWhTPINMg01l-sFQA1Mqks5vOv3WgaJpZM4bBe1V .
-- Edroaldo
Thanks for the quick response! Here is the source code of the plotPathHeatmap function I am using. Downloaded Dec. 14th 2018
setGeneric("plotPathHeatmap", function(object, paths, genelist, threshold=2, width, height, dir) standardGeneric("plotPathHeatmap"))
setMethod("plotPathHeatmap",
signature="CellRouter",
definition=function(object, paths, genelist, threshold, width, height, dir){
#plotPathHeatmap <- function(corsPaths, pathsInfo, graph, num_genes, width, height, dir){
corsPaths <- object@correlation
pathsInfo <- object@pathsinfo
sampTab <- object@sampTab
for(path in paths){
genelist2 <- intersect(genelist, rownames(pathsInfo$distr[[path]]))
tmpexpr <- pathsInfo$distr[[path]][genelist2,]
tmpexpr <- center_with_threshold(tmpexpr, 1.5) #double check this....
#andf <- data.frame(sampTab[pathsInfo$path[[path]], 'community',])
andf <- data.frame(sampTab[pathsInfo$path[[path]], 'population',])
rownames(andf) <- pathsInfo$path[[path]]
colnames(andf) <- c('subpopulation')
target_colors <- unique(sampTab[pathsInfo$path[[path]], 'colors',])
names(target_colors) <- unique(andf$subpopulation)
ann_colors = list(
subpopulation = target_colors
)
from <- sapply(strsplit(path, split='.', fixed=TRUE), function(x){x[1]})
to <- sapply(strsplit(path, split='.', fixed=TRUE), function(x){x[2]})
title <- paste('Transition ', from, ' ', to, sep='')
file <- paste(dir, 'heatmap_top_', path, '.pdf', sep='')
labels <- sapply(strsplit(rownames(tmpexpr), split='__', fixed=TRUE), function(x){x[1]})
#pheatmap(center_with_threshold(tmpexpr, threshold), cluster_rows = FALSE,
#pheatmap(tmpexpr, cluster_rows = TRUE,
pheatmap(tmpexpr, cluster_rows = FALSE,
cluster_cols = FALSE,
annotation_col = andf, annotation_colors=ann_colors,
show_colnames = FALSE, border=FALSE, main=title, filename = file,
width = width, height=height, labels_row = labels)
#to show plot in the report
pheatmap(tmpexpr, cluster_rows = FALSE,
cluster_cols = FALSE,
annotation_col = andf, annotation_colors=ann_colors,
show_colnames = FALSE, border=FALSE, main=title, labels_row = labels)
}
}
)
This looks correct. No sure if it will make any difference but can you try:
plotPathHeatmap(cellrouter, '8.9', genelist, 2, 4, 2, dir = 'results/heatmap')
The function expects a prefix to the file name, without the .pdf extension.
Can you please try that and let me know?
Thanks!
Em seg, 18 de fev de 2019 às 15:33, hgb1111 notifications@github.com escreveu:
Thanks for the quick response! Here is the source code of the plotPathHeatmap function I am using. Downloaded Dec. 14th 2018
setGeneric("plotPathHeatmap", function(object, paths, genelist, threshold=2, width, height, dir) standardGeneric("plotPathHeatmap")) setMethod("plotPathHeatmap", signature="CellRouter", definition=function(object, paths, genelist, threshold, width, height, dir){
#plotPathHeatmap <- function(corsPaths, pathsInfo, graph, num_genes, width, height, dir){ corsPaths <- object@correlation pathsInfo <- object@pathsinfo sampTab <- object@sampTab for(path in paths){ genelist2 <- intersect(genelist, rownames(pathsInfo$distr[[path]])) tmpexpr <- pathsInfo$distr[[path]][genelist2,] tmpexpr <- center_with_threshold(tmpexpr, 1.5) #double check this.... #andf <- data.frame(sampTab[pathsInfo$path[[path]], 'community',]) andf <- data.frame(sampTab[pathsInfo$path[[path]], 'population',]) rownames(andf) <- pathsInfo$path[[path]] colnames(andf) <- c('subpopulation') target_colors <- unique(sampTab[pathsInfo$path[[path]], 'colors',]) names(target_colors) <- unique(andf$subpopulation) ann_colors = list( subpopulation = target_colors ) from <- sapply(strsplit(path, split='.', fixed=TRUE), function(x){x[1]}) to <- sapply(strsplit(path, split='.', fixed=TRUE), function(x){x[2]}) title <- paste('Transition ', from, ' ', to, sep='') file <- paste(dir, 'heatmap_top_', path, '.pdf', sep='') labels <- sapply(strsplit(rownames(tmpexpr), split='__', fixed=TRUE), function(x){x[1]}) #pheatmap(center_with_threshold(tmpexpr, threshold), cluster_rows = FALSE, #pheatmap(tmpexpr, cluster_rows = TRUE, pheatmap(tmpexpr, cluster_rows = FALSE, cluster_cols = FALSE, annotation_col = andf, annotation_colors=ann_colors, show_colnames = FALSE, border=FALSE, main=title, filename = file, width = width, height=height, labels_row = labels) #to show plot in the report pheatmap(tmpexpr, cluster_rows = FALSE, cluster_cols = FALSE, annotation_col = andf, annotation_colors=ann_colors, show_colnames = FALSE, border=FALSE, main=title, labels_row = labels) } }
)
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/edroaldo/cellrouter/issues/20#issuecomment-464868433, or mute the thread https://github.com/notifications/unsubscribe-auth/AJqUR8XsUO-3DN862c-JdgcR0ny2fegTks5vOw4qgaJpZM4bBe1V .
-- Edroaldo
Okay so I found the source of the error: it boils down to the fact that this function assumes your different cell types are annotated in the SampTab as 'population' which is buried in the line of code below:
andf <- data.frame(sampTab[pathsInfo$path[[path]], 'population',])
Unlike other functions in cell router, which allow you to write in your column annotation, this function assumes that the column is named 'population.' The problem can be fixed by changing either 1) the name of your cell identities column to "population" or 2) going ahead and changing it in the source code to whatever the name of your column is, mine was "SrtClust" as I was working from clusters annotated in Seurat
If you're lazy and change it in the source code like I did, you will also need to change the command that chooses where to get the colors from - I changed 'colors' to 'SrtClust_color' as it was named in the SampTab
target_colors <- unique(sampTab[pathsInfo$path[[path]], 'colors',])
Thanks for finding the issue. I will fix it in the next few days and push it to github.
Thanks a lot! I really appreciate it!
Em seg, 25 de fev de 2019 às 18:59, hgb1111 notifications@github.com escreveu:
Okay so I found the source of the error: it boils down to the fact that this function assumes your different cell types are annotated in the SampTab as 'population' which is buried in the line of code below:
andf <- data.frame(sampTab[pathsInfo$path[[path]], 'population',])
Unlike other functions in cell router, which allow you to write in your column annotation, this function assumes that the column is named 'population.' The problem can be fixed by changing either 1) the name of your cell identities column to "population" or 2) going ahead and changing it in the source code to whatever the name of your column is, mine was "SrtClust" as I was working from clusters annotated in Seurat
If you're lazy and change it in the source code like I did, you will also need to change the command that chooses where to get the colors from - I changed 'colors' to 'SrtClust_color' as it was named in the SampTab
target_colors <- unique(sampTab[pathsInfo$path[[path]], 'colors',])
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/edroaldo/cellrouter/issues/20#issuecomment-467234466, or mute the thread https://github.com/notifications/unsubscribe-auth/AJqUR7K8Hu3xSfqTh3ZAEwXIseIZeO-iks5vRHjjgaJpZM4bBe1V .
-- Edroaldo
When I run:
the plottrajectories function runs just fine.
When I try to run plotPathHeatmap with the same genelist:
I get the error:
How can I make a heatmap with the desired genes?