Starlitnightly / omicverse

A python library for multi omics included bulk, single cell and spatial RNA-seq analysis.
https://starlitnightly.github.io/omicverse/
GNU General Public License v3.0
469 stars 57 forks source link

An error occurred when running the pt.pl.coda.boxplots function. #153

Closed Zstark11 closed 1 month ago

Zstark11 commented 1 month ago

Describe the bug When using the pt.pl.coda.boxplots function, an AttributeError occurs: AttributeError: module 'pertpy.plot' has no attribute 'coda', which prevents the function from executing successfully.

To Reproduce Steps to reproduce the behavior:

  1. Python runtime environment and version:I have tried versions Python 3.9, 3.10, and 3.12. The pertpy version is 0.9.4, and I have also tried downgrading it to versions 0.8.0 through 0.5.0. The omicverse version is 1.6.6.

  2. Run the following code:

    import omicverse as ov
    import scanpy as sc
    import scvelo as scv
    import pertpy as pt
    ov.utils.ov_plot_set()
    adata=ov.read(r'D:\Python单细胞\test-haber\haber_count.h5ad')
    adata
    adata.obs['condition'].cat.categories
    ##
    sccoda_model = pt.tl.Sccoda()
    sccoda_data = sccoda_model.load(
    adata,
    type="cell_level",
    generate_sample_level=True,
    cell_type_identifier="cell_label",
    sample_identifier="batch",
    covariate_obs=["condition"],
    )
    sccoda_data
    ##
    pt.pl.coda.boxplots(
    sccoda_data,
    modality_key="coda",
    feature_name="condition",
    figsize=(12, 5),
    add_dots=True,
    args_swarmplot={"palette": ["red"]},
    )
    plt.show()

  3. See error: AttributeError: module 'pertpy.plot' has no attribute 'coda'。 Regarding the installation of pertpy, following pip install 'pertpy [coda]' still yields an error AttributeError: module 'pertupy. plot' has no attribute 'coda'

Zstark11 commented 1 month ago

The problem has been resolved. For the latest version 0.9.4 of Pertpy, the drawing function needs to be changed. For example, pt. pl. coda. boxplots need to be changed to sccoda_model.plot_boxplots. I hope this can help everyone.

Dexterssssss commented 1 week ago

@Zstark11 It worked. Thank you for sharing.