zhanghao-njmu / SCP

An end-to-end Single-Cell Pipeline designed to facilitate comprehensive analysis and exploration of single-cell data.
https://zhanghao-njmu.github.io/SCP/
GNU General Public License v3.0
351 stars 79 forks source link

Can we change/normalize y axis in FeatureStatPlot #179

Closed nbutyrate closed 10 months ago

nbutyrate commented 10 months ago

Hi,

thanks for the great tool,

Is there any way to change/normalize the y-axis in FeatureStatPlot? I understand that currently it utilizes the expression data stored in the 'data' slot in default, but can we do something like relative abundance or any other normalization?

Thanks in advance

zhanghao-njmu commented 10 months ago

You can install the latest version of SCP. I have removed the restriction in FeatureStatPlot that required the slot parameter to be either "counts" or "data". Therefore, in the new version of FeatureStatPlot, you can use the scale.data slot to plot. You can apply various methods to scale or normalize the data/counts, and then store the results in scale.data. When plotting with FeatureStatPlot, you can specify the parameter slot="scale.data":

data <- pancreas_sub@assays$RNA@data
pancreas_sub@assays$RNA@scale.data <- as.matrix(data / rowMeans(data))
FeatureStatPlot(pancreas_sub,
  stat.by = c("Neurog3", "Rbp4", "Ins1"), group.by = "CellType",
  slot = "scale.data", ylab = "FoldChange", same.y.lims = TRUE, y.max = 4
)

image

nbutyrate commented 10 months ago

Thanks

I tried to do the same, currently getting the following error

Error in ExpressionStatPlot(exp.data = exp.data, meta.data = meta.data, : 'stat.by' must be type of numeric variable.

nbutyrate commented 10 months ago

please ignore my previous message, got it working thanks fo your help.