swiftcnv.SwiftCNV

swiftcnv.SwiftCNV#

class SwiftCNV(counts, cell_order, gene_order)#

Bases: object

Python implementation of the inferCNV algorithm for inferring copy number variations from scRNA-seq data.

Direct implementation of the R inferCNV pipeline:

broadinstitute/infercnv

Parameters:
  • counts (scipy.sparse.csc_matrix (cells x genes))

  • ref_cells (numpy.ndarray) – True for reference cells, False for query (obs) cells

  • gene_order (pandas.DataFrame) – DataFrame with columns [‘gene’, ‘chr’, ‘arm’, ‘chr_arm’, ‘start’, ‘end’]

plot(groups=None, region_key='chr_arm', **kwargs)#

Helper to run plot_cnv() from a Swiftcnv object that has finished the run. If groups is defined, it calls plot_cnv_multi() with those groups.

run(cutoff=0.1, min_cells_per_gene=3, bound_sd_amplifier=3.0, substract_reference_by_sample=False, smooth_by='arm', bases_window=None, genes_window=None, denoise=True, noise_filter=0.1, sd_amplifier=1.0, noise_logistic=True, final_cap=1.5, inv_log=False)#

Run the full SwiftCNV pipeline.

Parameters:
  • cutoff (float, default 0.1) – Filter genes with normalized expression below this threshold.

  • min_cells_per_gene (int, default 3) – Filter genes expressed in fewer than this number of cells.

  • bound_sd_amplifier (float, default 3.0) – Bound values to this multiple of the standard deviation of the matrix, in log scale.

  • substract_reference_by_sample (bool, default False) – Subtract the mean of the reference for each sample.

  • smooth_by ({'chr', 'arm'}, default 'arm') – Stratify gene smoothing by chromosome or chromosome arm.

  • bases_window (float or None, default None) – Window size in megabases (Mb) used for smoothing.

  • genes_window (int or None, default None) – Window size in number of genes used for smoothing.

  • denoise (bool, default True) – Denoise low values that are likely to represent noise.

  • noise_filter (float, default 0.1) – Threshold below which values are considered noise.

  • sd_amplifier (float, default 1.0) – Multiplier of the standard deviation used to identify noise. Values with absolute magnitude below std * sd_amplifier are considered noise.

  • noise_logistic (bool, default True) – Smooth denoised values with a logistic function instead of setting them directly to zero.

  • final_cap (float, default 1.5) – Hard-clip the final values to the range [-final_cap, final_cap].

  • inv_log (bool, default False) – Apply the inverse log transformation exp(x) - 1 to the returned matrix, centering the values around 1 instead of 0.

Returns:

CNV matrix stored in self.expr.

Return type:

numpy.array