icbi-lab / infercnvpy

Infer copy number variation (CNV) from scRNA-seq data. Plays nicely with Scanpy.
https://infercnvpy.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
132 stars 27 forks source link

infercnvpy.pl.chromosome_heatmap shows 1e9 map values for copykat results #78

Open zsfrbkv opened 1 year ago

zsfrbkv commented 1 year ago

Report

Thank you for your wrapper for copykat, very useful!

I was wondering what can be done to remove values over 1e9 from the plot?

I use the following code on my dataset:

infercnvpy.tl.copykat(adata_ref1, inplace=True, norm_cell_names=adata_ref1[adata_ref1.obs['annotation_level_2'].isin(['Myeloid', 'Vascular', 'Lymphoid'])].obs.index)
infercnvpy.pl.chromosome_heatmap(adata_ref1, groupby="annotation_level_3")

image

Version information


anndata 0.8.0 infercnvpy 0.4.2 matplotlib 3.7.1 numpy 1.23.5 pandas 1.5.3 rpy2 3.5.10 scanpy 1.9.3 scipy 1.10.1 seaborn 0.12.2 session_info 1.0.0 tqdm 4.65.0

PIL 9.4.0 asttokens NA backcall 0.2.0 backports NA cffi 1.15.1 comm 0.1.3 cycler 0.10.0 cython_runtime NA dateutil 2.8.2 debugpy 1.6.6 decorator 5.1.1 defusedxml 0.7.1 executing 1.2.0 gtfparse NA h5py 3.8.0 igraph 0.10.4 importlib_metadata NA importlib_resources NA ipykernel 6.22.0 ipython_genutils 0.2.0 ipywidgets 8.0.6 jedi 0.18.2 jinja2 3.1.2 joblib 1.2.0 jupyter_server 2.5.0 kiwisolver 1.4.4 leidenalg 0.9.1 llvmlite 0.39.1 markupsafe 2.1.2 matplotlib_inline 0.1.6 mpl_toolkits NA natsort 8.3.1 numba 0.56.4 packaging 23.0 parso 0.8.3 pexpect 4.8.0 pickleshare 0.7.5 pkg_resources NA platformdirs 3.2.0 polars 0.16.16 prompt_toolkit 3.0.38 psutil 5.9.4 ptyprocess 0.7.0 pure_eval 0.2.2 pydev_ipython NA pydevconsole NA pydevd 2.9.5 pydevd_file_utils NA pydevd_plugins NA pydevd_tracing NA pygments 2.14.0 pyparsing 3.0.9 pyreadr 0.4.7 pytz 2023.3 pytz_deprecation_shim NA setuptools 67.6.1 six 1.16.0 sklearn 1.2.2 stack_data 0.6.2 statsmodels 0.13.5 texttable 1.6.7 threadpoolctl 3.1.0 tornado 6.2 traitlets 5.9.0 typing_extensions NA tzlocal NA wcwidth 0.2.6 yaml 6.0 zipp NA zmq 25.0.2

IPython 8.11.0 jupyter_client 8.1.0 jupyter_core 5.3.0 jupyterlab 3.5.0 notebook 6.5.3

Python 3.8.16 (default, Jan 17 2023, 23:13:24) [GCC 11.2.0] Linux-3.10.0-1160.76.1.el7.x86_64-x86_64-with-glibc2.17

Session information updated at 2023-04-04 13:42

grst commented 1 year ago

Hi @zseferbekova,

in principle, you can manipulate the matrix in adata.obsm["X_cnv"] before plotting. However, looking at the matrix, it seems something is wrong, as you have literally no variation between the chromosomal positions.

Here are some suggestions what you could check:

Cheers, Gregor

zsfrbkv commented 1 year ago

Thank you, Gregor @grst!

I was thinking the same thing, and indeed in the resultant matrix, there are values around 1e9. However, CopyKat itself saves plots that seem quite normal, e.g. (it creates them automatically after finishing the run): image

So I was wondering, is it the plotting function that is not adjusted for plotting CopyKat results?

grst commented 1 year ago

I'm wondering if the problem is just the plotting, or if something goes wrong when loading the copykat results into python.

Could you maybe try to plot adata.obsm["X_cnv"] with an external plotting library (e.g. seaborn clustermap)?

zsfrbkv commented 1 year ago

I tried sns.clustermap on adata.obsm["X_cnv"] and the results are the same. however, if I import copykat_result_copykat_CNA_results.txt manually and plot it, the result is somewhat similar to the plot above:

cnvs = pd.read_table('copykat_full_transcriptome/copykat_result_copykat_CNA_results.txt')
cnvs = cnvs.iloc[:, 3:]
sns.clustermap(cnvs.T.values)

image so I believe for copykat one needs to preprocess the resultant matrix before plotting it. however, I could not find any docs for copykat with a detailed explanation of what is needed to be done :(