broadinstitute / infercnv

Inferring CNV from Single-Cell RNA-Seq
Other
557 stars 164 forks source link

Tumor subcluster partition method question #595

Open jemorlanes opened 1 year ago

jemorlanes commented 1 year ago

Hey all! Amazing package :). I had a question regarding the arguments for tumor_subcluster_partition_method. Over there you have several methods to choose from for the subclustering. However, only if you choose the leiden algorithm are you allowed to modify the resolution of the subclustering downstream right? leiden_resolution.

If I want to run qnorm as the subclustering method but allow for a smaller resolution to feed to the HMM later, how would I go about it? This is my inferCNV run call: infercnv::run(object, cutoff = 0.1, out_dir = output_dir, smooth_method = "pyramidinal", # default ref_subtract_use_mean_bounds = TRUE, # default, computes mean expression for each group reference. if we are working with all the samples then the mean is sample-wise cluster_by_groups = TRUE, # cluster the query by the groups. If we have multiple annotations in the query, it will cluster within each group cluster_references = TRUE, #default hclust_method = "ward.D2", #default HMM=FALSE, #default HMM_report_by = "subcluster", # give me an HMM prediction for each leiden subcluster analysis_mode = "subclusters", # let's try with this greater res tumor_subcluster_partition_method = "qnorm", denoise=TRUE, leiden_resolution=0.01, #WE ARE RUNNING QNORM SO THIS SHOULDNT AFFECT AT ALL. default is 0.05. We increase it if we want more clusters, decrease it if we want less. up_to_step=15, # to test if this resolution makes sense num_threads = 15 )

GeorgescuC commented 10 months ago

Hi @jemorlanes ,

For the qnorm method, the argument that controls the "resolution" is tumor_subcluster_pval. The code for it is very simple:

hc <- hclust(parallelDist(t(tumor_expr_data), threads=infercnv.env$GLOBAL_NUM_THREADS), method=hclust_method)
heights = hc$height

mu = mean(heights)
sigma = sd(heights)

cut_height = qnorm(p=1-tumor_subcluster_pval, mean=mu, sd=sigma)
grps <- cutree(hc, h=cut_height)

Regards, Christophe.

jemorlanes commented 10 months ago

Aha I see! So if I want to include more cells in each qnorm subcluster, should I increase tumor_subcluster_pval when running infercnv::run(), or should I run the snippet you wrote as an intermediate step?

Thank you for your help! :)