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
163 stars 27 forks source link

ValueError: Length mismatch: Expected axis has 0 elements, new values have 3 elements #285

Open Sudheshna30 opened 5 months ago

Sudheshna30 commented 5 months ago

I keep getting this error for the below step may I know how to solve this @SeppeDeWinter

ValueError Traceback (most recent call last) Cell In[11], line 3 1 tmp_dir= '/n/holyscratch01/arlotta_lab/Sudheshna/' 2 from scenicplus.wrappers.run_pycistarget import run_pycistarget ----> 3 run_pycistarget( 4 region_sets = region_sets, 5 species = 'mus_musculus', 6 save_path = os.path.join(work_dir, 'motifs'), 7 ctx_db_path = rankings_db, 8 dem_db_path = scores_db, 9 path_to_motif_annotations = motif_annotation, 10 run_without_promoters = True, 11 n_cpu = 1, 12 _temp_dir = os.path.join(tmp_dir, 'ray_spill'), 13 annotation_version = 'v10nr_clust', 14 )

File /n/holyscratch01/arlotta_lab/Sudheshna/scenicplus/src/scenicplus/wrappers/run_pycistarget.py:263, in run_pycistarget(region_sets, species, save_path, custom_annot, save_partial, ctx_db_path, dem_db_path, run_without_promoters, biomart_host, promoter_space, ctx_auc_threshold, ctx_nes_threshold, ctx_rank_threshold, dem_log2fc_thr, dem_motif_hit_thr, dem_max_bg_regions, annotation, motif_similarity_fdr, path_to_motif_annotations, annotation_version, n_cpu, _temp_dir, exclude_motifs, exclude_collection, kwargs) 261 for col in exclude_collection: 262 dem_db.db_scores = dem_db.db_scores[~dem_db.dbscores.index.str.contains(col)] --> 263 menr['DEM'+key+'_All'] = DEM(dem_db = dem_db, 264 region_sets = regions, 265 log2fc_thr = dem_log2fc_thr, 266 motif_hit_thr = dem_motif_hit_thr, 267 max_bg_regions = dem_max_bg_regions, 268 specie = species, 269 genome_annotation = annot_dem, 270 promoter_space = promoter_space, 271 motif_annotation = annotation, 272 motif_similarity_fdr = motif_similarity_fdr, 273 path_to_motif_annotations = path_to_motif_annotations, 274 n_cpu = n_cpu, 275 annotation_version = annotation_version, 276 tmp_dir = save_path, 277 _temp_dir= _temp_dir, 278 kwargs) 279 out_folder = os.path.join(savepath,'DEM'+key+'_All') 280 check_folder = os.path.isdir(out_folder)

File ~/miniconda3/envs/scenicplus/lib/python3.9/site-packages/pycistarget/motif_enrichment_dem.py:319, in DEM.init(self, dem_db, region_sets, specie, subset_motifs, contrasts, name, max_bg_regions, adjpval_thr, log2fc_thr, mean_fg_thr, motif_hit_thr, n_cpu, fraction_overlap, cluster_buster_path, path_to_genome_fasta, path_to_motifs, genome_annotation, promoter_space, path_to_motif_annotations, annotation_version, motif_annotation, motif_similarity_fdr, orthologous_identity_threshold, tmp_dir, kwargs) 317 self.cistromes = None 318 if dem_db is not None: --> 319 self.run(dem_db.db_scores, kwargs)

File ~/miniconda3/envs/scenicplus/lib/python3.9/site-packages/pycistarget/motif_enrichment_dem.py:365, in DEM.run(self, dem_db_scores, kwargs) 363 # Get region groups 364 log.info('Creating contrast groups') --> 365 region_groups = [create_groups(contrast = contrasts[x], 366 region_sets_names = region_sets_names, 367 max_bg_regions = self.max_bg_regions, 368 path_to_genome_fasta = self.path_to_genome_fasta, 369 path_to_regions_fasta = os.path.join(self.tmp_dir, contrasts_names[x] +'.fa'),
370 cbust_path = self.cluster_buster_path, 371 path_to_motifs = self.path_to_motifs, 372 annotation = self.genome_annotation, 373 promoter_space = self.promoter_space, 374 motifs = dem_db_scores.index.tolist(), 375 n_cpu = self.n_cpu, 376
kwargs) for x in range(len(contrasts))] 378 # Compute p-val and log2FC 379 if self.n_cpu > len(region_groups):

File ~/miniconda3/envs/scenicplus/lib/python3.9/site-packages/pycistarget/motif_enrichment_dem.py:365, in (.0) 363 # Get region groups 364 log.info('Creating contrast groups') --> 365 region_groups = [create_groups(contrast = contrasts[x], 366 region_sets_names = region_sets_names, 367 max_bg_regions = self.max_bg_regions, 368 path_to_genome_fasta = self.path_to_genome_fasta, 369 path_to_regions_fasta = os.path.join(self.tmp_dir, contrasts_names[x] +'.fa'),
370 cbust_path = self.cluster_buster_path, 371 path_to_motifs = self.path_to_motifs, 372 annotation = self.genome_annotation, 373 promoter_space = self.promoter_space, 374 motifs = dem_db_scores.index.tolist(), 375 n_cpu = self.n_cpu, 376 **kwargs) for x in range(len(contrasts))] 378 # Compute p-val and log2FC 379 if self.n_cpu > len(region_groups):

File ~/miniconda3/envs/scenicplus/lib/python3.9/site-packages/pycistarget/motif_enrichment_dem.py:534, in create_groups(contrast, region_sets_names, max_bg_regions, path_to_genome_fasta, path_to_regions_fasta, cbust_path, path_to_motifs, annotation, promoter_space, motifs, n_cpu, **kwargs) 532 nr_no_pr = max_bg_regions-nr_pr 533 # Nr of promoters in the background --> 534 bg_pr_overlap = pr.PyRanges(region_names_to_coordinates(background)).count_overlaps(annotation) 535 bg_pr = coord_to_region_names(bg_pr_overlap[bg_pr_overlap.NumberOverlaps != 0][['Chromosome', 'Start', 'End']]) 536 bg_no_pr = coord_to_region_names(bg_pr_overlap[bg_pr_overlap.NumberOverlaps == 0][['Chromosome', 'Start', 'End']])

File ~/miniconda3/envs/scenicplus/lib/python3.9/site-packages/pycistarget/utils.py:33, in region_names_to_coordinates(region_names) 31 regiondf=pd.concat([chrom, start, end], axis=1, sort=False) 32 regiondf.index=[i for i in region_names if ':' in i] ---> 33 regiondf.columns=['Chromosome', 'Start', 'End'] 34 return(regiondf)

File ~/miniconda3/envs/scenicplus/lib/python3.9/site-packages/pandas/core/generic.py:5920, in NDFrame.setattr(self, name, value) 5918 try: 5919 object.getattribute(self, name) -> 5920 return object.setattr(self, name, value) 5921 except AttributeError: 5922 pass

File ~/miniconda3/envs/scenicplus/lib/python3.9/site-packages/pandas/_libs/properties.pyx:69, in pandas._libs.properties.AxisProperty.set()

File ~/miniconda3/envs/scenicplus/lib/python3.9/site-packages/pandas/core/generic.py:822, in NDFrame._set_axis(self, axis, labels) 820 def _set_axis(self, axis: int, labels: AnyArrayLike | list) -> None: 821 labels = ensure_index(labels) --> 822 self._mgr.set_axis(axis, labels) 823 self._clear_item_cache()

File ~/miniconda3/envs/scenicplus/lib/python3.9/site-packages/pandas/core/internals/managers.py:228, in BaseBlockManager.set_axis(self, axis, new_labels) 226 def set_axis(self, axis: int, new_labels: Index) -> None: 227 # Caller is responsible for ensuring we have an Index object. --> 228 self._validate_set_axis(axis, new_labels) 229 self.axes[axis] = new_labels

File ~/miniconda3/envs/scenicplus/lib/python3.9/site-packages/pandas/core/internals/base.py:70, in DataManager._validate_set_axis(self, axis, new_labels) 67 pass 69 elif new_len != old_len: ---> 70 raise ValueError( 71 f"Length mismatch: Expected axis has {old_len} elements, new " 72 f"values have {new_len} elements" 73 )

ValueError: Length mismatch: Expected axis has 0 elements, new values have 3 element

jklvrt commented 5 months ago

Having this exact same issue now! @SeppeDeWinter please save us :)

SeppeDeWinter commented 5 months ago

Hi @Sudheshna30 and @jklvrt

Please see: https://github.com/aertslab/scenicplus/discussions/286

All the best,

Seppe