How to set aspect ratio and symmetric colour map in iSEE panels?
1
1
Entering edit mode
jma1991 ▴ 70
@jma1991-11856
Last seen 12 months ago
Cumbernauld

Is is possible to set the aspect ratio in the reduced dimension panel within iSEE? For example, I would like the PCA slot to use coord_fixed(ratio = 1) and the TSNE/UMAP slots to force the same axis length (e.g. aspect.ratio = 1). Additionally, I have a number of z-scores in the column data of my experiment object. When these are coloured on the reduced dimension panel, it defaults to the viridis colour palette. Instead, I would like a symmetric colour palette around zero (e.g. -abs to +abs).

iSEE • 1.0k views
ADD COMMENT
0
Entering edit mode
kevin.rue ▴ 350
@kevinrue-6757
Last seen 16 days ago
University of Oxford

Hi jma1991

In the current version of the code it's not possible to set the aspect ratio. However it's entirely possible - and rather straightforward - to add a UI input to relevant panels and generate the corresponding coord_fixed(ratio = 1) bit of code in the code tracker. Can you please open an issue with the feature request? We'll get on it as soon as time allows.

It is possible to provide custom colormaps to the iSEE app using the ExperimentColorMap

Using the example in the ?iSEE man page, as a brute force example, I'm setting a symmetric colormap that will be applied exclusively to the "PCT_RIBOSOMAL_BASES" colData column, while all other covariates will use the default continuous colormap. See the ExperimentColorMap vignette and man pages for more details.

library(scRNAseq)

# Example data ----
sce <- ReprocessedAllenData(assays="tophat_counts")
class(sce)

library(scater)
sce <- logNormCounts(sce, exprs_values="tophat_counts")

sce <- runPCA(sce, ncomponents=4)
sce <- runTSNE(sce)
rowData(sce)$ave_count <- rowMeans(assay(sce, "tophat_counts"))
rowData(sce)$n_cells <- rowSums(assay(sce, "tophat_counts") > 0)
sce

# ExperimentColorMap ----

rwb <- colorRampPalette(colors = c("red", "grey", "blue"))

ecm <- ExperimentColorMap(
    colData = list(
        PCT_RIBOSOMAL_BASES = rwb
    )
)

# launch the app itself ----

app <- iSEE(sce, colormap = ecm)
if (interactive()) {
  shiny::runApp(app, port=1234)
}

In the future, please open one post per question that you have, so that we can mark them answered separately.

Thank you for your feedback! Kevin

ADD COMMENT
0
Entering edit mode

Thank you for replying Kevin, I will open a feature request on GitHub regarding the aspect ratio. Regarding the colour scale, I've realised what I actually want is to have the limits of the scale equidistant from zero. For example, if I generate a new column with a hypothetical z-score and one extreme positive value, white is no longer the middle colour (i.e. at zero).

Example

library(scRNAseq)

# Example data ----
sce <- ReprocessedAllenData(assays="tophat_counts")
class(sce)

library(scater)
sce <- logNormCounts(sce, exprs_values="tophat_counts")

sce <- runPCA(sce, ncomponents=4)
sce <- runTSNE(sce)
rowData(sce)$ave_count <- rowMeans(assay(sce, "tophat_counts"))
rowData(sce)$n_cells <- rowSums(assay(sce, "tophat_counts") > 0)

# Example variable ----

sce$score <- rnorm(n = ncol(sce), mean = 0, sd = 1)

sce$score[1] <- 10 # one extreme value 

# ExperimentColorMap ----

rwb <- colorRampPalette(colors = c("red", "white", "blue"))

ecm <- ExperimentColorMap(
    colData = list(
        score = rwb
    )
)

# launch the app itself ----

app <- iSEE(sce, colormap = ecm)
if (interactive()) {
  shiny::runApp(app, port=1234)
}
ADD REPLY
1
Entering edit mode

Indeed, I just checked and our current framework will return the same vector of colors irrespective or what the values are (neither the plotted, nor the full range of values if the panel only shows a subset

If you look at the code tracker in the example iSEE app, colored by "TOTAL_DUP" colData, you'll something like:

scale_color_gradientn(colors=colDataColorMap(colormap, "TOTAL_DUP", discrete=FALSE)(21), na.value='grey50', limits=range(plot.data$ColorBy, na.rm=TRUE))

This bit fetches the colormap function:

colDataColorMap(colormap, "TOTAL_DUP", discrete=FALSE)

And it is used to fetch a vector of 21 colors without being told anything about the values (e.g. their range)

> colDataColorMap(colormap, "TOTAL_DUP", discrete=FALSE)(21)
 [1] "#440154FF" "#481467FF" "#482576FF" "#463480FF" "#414487FF" "#3B528BFF" "#35608DFF" "#2F6C8EFF"
 [9] "#2A788EFF" "#25848EFF" "#21908CFF" "#1E9C89FF" "#22A884FF" "#2FB47CFF" "#43BF71FF" "#5DC863FF"
[17] "#7AD151FF" "#9AD93CFF" "#BBDF27FF" "#DEE318FF" "#FDE725FF"

I'd encourage you to open another issue for feature request, though that one would require a bit (a lot?) more thinking than your other questions, because it wouldn't just be another user-controlled UI input, but rather another of the iSEE features that is a combination of user input and automagical adaptation to the data at hand.

Best Kevin

ADD REPLY

Login before adding your answer.

Traffic: 893 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