Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidIndexError: (slice(None, None, None), 30751) while using coverage plot #493

Open
yojetsharma opened this issue Oct 25, 2024 · 2 comments

Comments

@yojetsharma
Copy link

genes_violin_plot = 'MAFIP'
region='chr9:39287963-39288463'
# Create a coverage plot
fig = coverage_plot(
    SCENICPLUS_obj=scplus_obj,  # Your SCENICPLUS object
    bw_dict=bw_dict,
    region=region,
    genes_violin_plot=genes_violin_plot,
    gene_height=1,
    exon_height=4,
    meta_data_key='broader_annotation',  # Adjust based on your metadata structure
    figsize=(8, 10)  # Adjust figure size as needed
)
scplus_obj.gene_names:
Index(['MIR1302-2HG', 'AL627309.1', 'AL627309.5', 'AL627309.4', 'AP006222.2',
       'AL669831.2', 'LINC01409', 'FAM87B', 'LINC01128', 'LINC00115',
       ...
       'MAFIP', 'AC011043.1', 'AC011043.2', 'AC011841.1', 'AL354822.1',
       'AL592183.1', 'AC240274.1', 'AC004556.3', 'AC007325.4', 'AC007325.2'],
      dtype='object', length=30761)
@SeppeDeWinter
Copy link
Collaborator

Hi @yojetsharma

Can you provide the full error output please?

All the best,

Seppe

@yojetsharma
Copy link
Author

yojetsharma commented Nov 11, 2024

The code in question was run using a different pr_annotation file (i will get back to you on that complete shortly). But the code I tried recently gave the following error (pr_annotation file was the same that is used for pycistopic analysis for this):

from scenicplus.plotting.coverageplot import coverage_plot
scenicplus.plotting.coverageplot.coverage_plot(
    scplus_obj,
    bw_dict=bw_dict,
    region='chr14:100725892-100739224',
    meta_data_key='broader_annotation',
    pr_consensus_bed=pr_consensus_bed,
    pr_gtf=pr_annotation,
    genes_violin_plot='DLK1'
)

/home/praghu/yojetsharma/.conda/envs/scenicplus/lib/python3.11/site-packages/pyranges/methods/intersection.py:52: FutureWarning: In a future version, df.iloc[:, i] = newvals will attempt to set the values inplace instead of always setting a new array. To retain the old behavior, use either df[df.columns[i]] = newvals or, if columns are non-unique, df.isetitem(i, newvals)
scdf.loc[:, "Start"] = new_starts
/home/praghu/yojetsharma/.conda/envs/scenicplus/lib/python3.11/site-packages/pyranges/methods/intersection.py:53: FutureWarning: In a future version, df.iloc[:, i] = newvals will attempt to set the values inplace instead of always setting a new array. To retain the old behavior, use either df[df.columns[i]] = newvals or, if columns are non-unique, df.isetitem(i, newvals)
scdf.loc[:, "End"] = new_ends

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[75], line 2
      1 from scenicplus.plotting.coverageplot import coverage_plot
----> 2 scenicplus.plotting.coverageplot.coverage_plot(
      3     scplus_obj,
      4     bw_dict=bw_dict,
      5     region='chr14:100725892-100739224',
      6     meta_data_key='broader_annotation',
      7     pr_consensus_bed=pr_consensus_bed,
      8     pr_gtf=pr_annotation,
      9     genes_violin_plot='DLK1'
     10 )

File ~/.conda/envs/scenicplus/lib/python3.11/site-packages/scenicplus/plotting/coverageplot.py:288, in coverage_plot(SCENICPLUS_obj, bw_dict, region, genes_violin_plot, genes_arcs, gene_height, exon_height, meta_data_key, pr_consensus_bed, region_bed_height, pr_gtf, pr_interact, bw_ymax, color_dict, cmap, plot_order, figsize, fontsize_dict, gene_label_offset, arc_rad, arc_lw, cmap_violinplots, violinplots_means_color, violinplots_edge_color, violoinplots_alpha, width_ratios_dict, height_ratios_dict, sort_vln_plots, add_custom_ax)
    283 gtf_region_intersect = pr_gtf.intersect(pr_region)
    284 # only keep exon and gene info
    285 gtf_region_intersect = gtf_region_intersect[np.logical_and(
    286     np.logical_or(gtf_region_intersect.Feature == 'gene',
    287                   gtf_region_intersect.Feature == 'exon'),
--> 288     gtf_region_intersect.gene_type == 'protein_coding')]
    289 # iterate over all genes in intersect
    290 ax = axs_bw[subplot_idx]

File ~/.conda/envs/scenicplus/lib/python3.11/site-packages/pyranges/pyranges.py:269, in PyRanges.__getattr__(self, name)
    244 """Return column.
    245 
    246 Parameters
   (...)
    264 Name: Start, dtype: int32
    265 """
    267 from pyranges.methods.attr import _getattr
--> 269 return _getattr(self, name)

File ~/.conda/envs/scenicplus/lib/python3.11/site-packages/pyranges/methods/attr.py:67, in _getattr(self, name)
     65     return pd.concat([df[name] for df in self.values()])
     66 else:
---> 67     raise AttributeError("PyRanges object has no attribute", name)

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

Screenshot from 2024-11-11 21-56-32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants