hemberg-lab / SC3

A tool for the unsupervised clustering of cells from single cell RNA-Seq experiments
http://bioconductor.org/packages/SC3
GNU General Public License v3.0
119 stars 55 forks source link

sc3_plot_de_genes and sc3_plot_markers not working #46

Closed yicheinchang closed 6 years ago

yicheinchang commented 6 years ago

Hi,

Somehow sc3 doesn't like my data set :) Both sc3_plot_de_genes and sc3_plot_markers are not not working. The command I used to run sc3 was provided in #45

sc3_plot_de_genes

sc3_plot_de_genes(SC3, k = 5)

Error in seq.default(min(x, na.rm = T), max(x, na.rm = T), length.out = n + : 'from' must be a finite number

8.stop("'from' must be a finite number")
7.seq.default(min(x, na.rm = T), max(x, na.rm = T), length.out = n + 1)
6.seq(min(x, na.rm = T), max(x, na.rm = T), length.out = n + 1)
5.generate_breaks(as.vector(mat), length(color))
4.(function (mat, color = colorRampPalette(rev(brewer.pal(n = 7, name = "RdYlBu")))(100), kmeans_k = NA, breaks = NA, border_color = "grey60", cellwidth = NA, cellheight = NA, scale = "none", cluster_rows = TRUE, cluster_cols = TRUE, clustering_distance_rows = "euclidean", ...
3.do.call(pheatmap::pheatmap, c(list(dataset[names(de_genes), , drop = FALSE], show_colnames = FALSE, cluster_rows = FALSE, cluster_cols = hc, cutree_cols = k, annotation_row = row_ann, cellheight = 10), list(annotation_col = ann)[add_ann_col]))

sc3_plot_markers

sc3_plot_markers(SCExp.filtered.normalized.tSNE.SC3, k = 5)

Error: subscript contains invalid names

10.stop(wmsg(...), call. = FALSE)
9..subscript_error("subscript contains invalid ", what)
8.NSBS(i, x, exact = exact, strict.upper.bound = !allow.append, allow.NAs = allow.NAs)
7.NSBS(i, x, exact = exact, strict.upper.bound = !allow.append, allow.NAs = allow.NAs)
6.normalizeSingleBracketSubscript(j, xstub)
5.rowData(object)[, c(paste0("sc3_", k, "_markers_clusts"), paste0("sc3_", k, "_markers_auroc"), paste0("sc3_", k, "_markers_padj"), "feature_symbol")]
4.rowData(object)[, c(paste0("sc3_", k, "_markers_clusts"), paste0("sc3_", k, "_markers_auroc"), paste0("sc3_", k, "_markers_padj"), "feature_symbol")]
3.organise_marker_genes(object, k, p.val, auroc)

session info

Thanks again.

yicheinchang commented 6 years ago

I figured out why those two functions not working. My data set was originally a SCESet object (by scater 1.4). After upgrading to Bioconductor 3.6, I converted it to a SingleCellExperiment object (by using updateSCESet) and then ran sc3. Everything looks fine after converting. However, somehow rowData missed "feature_symbol", one of the essential columns for sc3. After manually putting it back, then those two plot functions work.

rowData(sce)$feature_symbol <- rownames(sce)

One quick suggestion. Unless all input SingleCellExperiment object will have feature_symbol, you may not want to hard-code the column name in function organise_de_genes (in ShinyFunctions.R) A solution could be


organise_de_genes <- function(object, k, p_val) {
    de_genes <- rowData(object)[, paste0("sc3_", k, "_de_padj")]
    names(de_genes) <- rownames(object)
    de_genes <- de_genes[!is.na(de_genes)]
    de_genes <- de_genes[de_genes < p_val]
    de_genes <- de_genes[order(de_genes)]
    return(de_genes)
}
wikiselev commented 6 years ago

Great! Many thanks for this investigation, I will fix it this week!

wikiselev commented 6 years ago

Ok, in the latest version of SC3 (1.7.2) it will check for feature_symbol before running clustering, so there will be no problem in the downstream processing. I require this, because feature_symbol is the default column that scater writes to when using biomaRt to convert gene ids to names. The changes will appear on Bioconductor in a couple of days.

yicheinchang commented 6 years ago

@wikiselev Thank you!!! This solution is fine as long as a user will know how to 'fix' it (and make it work)