aertslab / scenicplus

SCENIC+ is a python package to build gene regulatory networks (GRNs) using combined or separate single-cell gene expression (scRNA-seq) and single-cell chromatin accessibility (scATAC-seq) data.
Other
165 stars 27 forks source link

compute_qc_stats error #226

Open MohammadIzadi opened 9 months ago

MohammadIzadi commented 9 months ago

Hi,

Thank you for developing SCENIC+. I am excited to use it. When I want to use compute_qc_stats(), I get below traceback.

AttributeError                            Traceback (most recent call last)
[<ipython-input-110-0d6f1cb8e2c7>](https://localhost:8080/#) in <cell line: 14>()
     12 path_to_regions = {'mahan': "/content/consensus_regions.bed"}
     13 sys.stderr = open(os.devnull, "w")  # silence stderr
---> 14 metadata_bc, profile_data_dict = compute_qc_stats(
     15                 fragments_dict = fragments_dict,
     16                 tss_annotation = annot,

5 frames
[/usr/local/lib/python3.10/dist-packages/pycisTopic/qc.py](https://localhost:8080/#) in compute_qc_stats(fragments_dict, tss_annotation, stats, label_list, path_to_regions, n_cpu, partition, valid_bc, n_frag, n_bc, tss_flank_window, tss_window, tss_minimum_signal_window, tss_rolling_window, min_norm, check_for_duplicates, remove_duplicates, use_polars, **kwargs)
   1031         ray.shutdown()
   1032     else:
-> 1033         qc_stats = [
   1034                 compute_qc_stats_single(
   1035                     fragments_list[i],

[/usr/local/lib/python3.10/dist-packages/pycisTopic/qc.py](https://localhost:8080/#) in <listcomp>(.0)
   1032     else:
   1033         qc_stats = [
-> 1034                 compute_qc_stats_single(
   1035                     fragments_list[i],
   1036                     tss_annotation=tss_annotation,

[/usr/local/lib/python3.10/dist-packages/pycisTopic/qc.py](https://localhost:8080/#) in compute_qc_stats_single(fragments, tss_annotation, stats, label, path_to_regions, valid_bc, n_frag, n_bc, tss_flank_window, tss_window, tss_minimum_signal_window, tss_rolling_window, min_norm, partition, check_for_duplicates, remove_duplicates, use_polars)
   1215         # TSS
   1216         log.info("Computing TSS profile for " + label)
-> 1217         profile_tss_metrics = profile_tss(
   1218             fragments=fragments_df,
   1219             annotation=tss_annotation,

[/usr/local/lib/python3.10/dist-packages/pycisTopic/qc.py](https://localhost:8080/#) in profile_tss(fragments, annotation, valid_bc, plot, plot_data, n_cpu, partition, flank_window, tss_window, minimum_signal_window, rolling_window, min_norm, color, save, return_TSS_enrichment_per_barcode, return_TSS_coverage_matrix_per_barcode, return_plot_data, use_polars)
    526             fragments = fragments[fragments.Name.isin(set(valid_bc))]
    527         else:
--> 528             valid_bc = list(set(fragments.Name.tolist()))
    529 
    530         log.info("Formatting annnotation")

[/usr/local/lib/python3.10/dist-packages/pyranges/pyranges_main.py](https://localhost:8080/#) in __getattr__(self, name)
    263         from pyranges.methods.attr import _getattr
    264 
--> 265         return _getattr(self, name)
    266 
    267     def __setattr__(self, column_name, column):

[/usr/local/lib/python3.10/dist-packages/pyranges/methods/attr.py](https://localhost:8080/#) in _getattr(self, name)
     63         return pd.concat([df[name] for df in self.values()])
     64     else:
---> 65         raise AttributeError("PyRanges object has no attribute", name)

AttributeError: ('PyRanges object has no attribute', 'Name')

Can you help me to fix it, please? Best,

SeppeDeWinter commented 9 months ago

Hi @MohammadIzadi

Can you show the head of your fragments file?

Best,

Seppe

MohammadIzadi commented 9 months ago

Hi @SeppeDeWinter,

Many Thanks for your response. I attached my fragments file in this comment. Thanks again for your help.

Best,

Mohammad

fragments.tsv.gz

SeppeDeWinter commented 9 months ago

Hi @MohammadIzadi

Can you also provide the full function you were running (with all parameters).

For the fragment file, I see that the 5th column is all 0. The column represents "the total number of read pairs associated with this fragment. This includes the read pair marked unique and all duplicate read pairs." (see https://support.10xgenomics.com/single-cell-atac/software/pipelines/latest/output/fragments) so 0 does not make a lot of sense.

Best,

Seppe

MohammadIzadi commented 9 months ago

Hi @SeppeDeWinter

Thanks for your response. I attached wrong fragments file and I upload it again. I convert anndata to fragments.tsv file and now I delete rows that have zero values. I attached again fragments file in this comment. I get screen shot from consensus_peaks and compute_qc_stats() parameters and I attached them. consensus_peaks variable have only one row. Is it correct? image image fragments(1).tsv.gz

SeppeDeWinter commented 9 months ago

Hi @MohammadIzadi

Having only a single consensus peak is not good! Something went wrong there.

Also I would not delete all rows with a zero count for your fragments file (probably the number 0 is wrong). Could you specify how exactly you generated your fragments file? The fragments are also quite long (5kb). A typical fragment size distribution looks like the plot below

image (from ArchR).

Best,

Seppe