... that focuses on the most useful markers for a particular test dataset. Specifically, we take all of the reference-derived markers and look at which of them are also DE in the test dataset and then we use those for visualizing expression.
Something like this:
for.viz # assume this is a test matrix
colnames(for.viz) <- seq_len(ncol(for.viz))
col.order <- order(predictions$labels)
all.markers <- metadata(predictions)$de.genes
uniq.lab <- unique(predictions$labels)
for (lab in uniq.lab) {
# Fetching all markers for this label.
keep <- rownames(test) %in% unlist(all.markers[[lab]])
current <- for.viz[keep,,drop=FALSE]
# Prioritize the markers with interesting variation in the test data for
# visualization. If we only have one label, we use the most abundant markers.
if (length(uniq.lab) > 1L) {
interesting <- scrapper::scoreMarkers(
current,
predictions$labels,
compute.auc=FALSE,
num.threads = BiocParallel::bpnworkers(BPPARAM)
)
cohen.stats <- interesting$cohens.d[[lab]]
o <- order(cohen.stats$min.rank)
to.show <- rownames(cohen.stats)[o]
} else {
abundance <- Matrix::rowMeans(current)
to.show <- names(abundance)[order(abundance, decreasing=TRUE)]
}
cat("\n\n##", lab, "{-}\n")
pheatmap::pheatmap(
current[head(to.show,20),col.order,drop=FALSE],
breaks=seq(0, max(for.viz) * 1.01, length.out=26),
color=viridis::viridis(25),
annotation_col=data.frame(
labels=predictions$labels,
row.names=colnames(current)
),
cluster_col=FALSE
)
}
The aim is to generate some nicer looking diagnostic plots without relying on users to manually configure pheatmap::pheatmap (or scater::plotHeatmap, for that matter).
... that focuses on the most useful markers for a particular test dataset. Specifically, we take all of the reference-derived markers and look at which of them are also DE in the test dataset and then we use those for visualizing expression.
Something like this:
The aim is to generate some nicer looking diagnostic plots without relying on users to manually configure
pheatmap::pheatmap
(orscater::plotHeatmap
, for that matter).