Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scale expression by row or column in FeatureStatPlot plot_type = "heatmap" #17

Open
guillemsanchezsanchez1996 opened this issue Jan 7, 2025 · 1 comment

Comments

@guillemsanchezsanchez1996

Hello in FeatureStatPlot with plot_type = "heatmap" option is there a way to scale the expression data according to row or column?

Thanks for this amazing package :)

Guillem

@pwwang
Copy link
Owner

pwwang commented Jan 8, 2025

Hi, scaling expression by row/column in heatmap by FeatureStatPlot is not supported directly.

You can use layer_fun_callback to tweak it:

data(pancreas_sub)
features <- c(
   "Sox9", "Anxa2", "Bicc1", # Ductal
   "Neurog3", "Hes6", # EPs
   "Fev", "Neurod1", # Pre-endocrine
   "Rbp4", "Pyy", # Endocrine
   "Ins1", "Gcg", "Sst", "Ghrl" # Beta, Alpha, Delta, Epsilon
)

# generate a row/column-scaled expression value matrix
scaled_exprs <- ...

FeatureStatPlot(pancreas_sub, features = features, ident = "SubCellType",
   plot_type = "heatmap", name = "Expression Level", layer_fun_callback = function(j, i, x, y, w, h, fill, sr, sc) {
        # i: row indexes
        # j: column indexes
        # get the values from scaled_exprs[i, j] and use grid::grid_rect() to draw tiles 
        # to override the tiles in each cell
   })

I am not arguing if it is a good idea to do so, but I think it might be better to split the rows/columns into different sub-plots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants