Skip to content

aggregate_across_cells functon : length of 'groups' should be equal to the number of columns in 'x'  #84

@xjsun1221

Description

@xjsun1221
import scranpy
import numpy as np

X = np.random.randint(0, 100, size=(50, 50)).astype(np.float64)

groups = np.random.choice(['A', 'B', 'C'], size=50).astype('U10')
print(X.shape,len(groups))

single_factor_result = scranpy.aggregate_across_cells(
    x=X,          
    factors=groups,  
    num_threads=1
)
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[20], line 2
      1 # 执行聚合
----> 2 single_factor_result = scranpy.aggregate_across_cells(
      3     x=X,          
      4     factors=groups,  
      5     num_threads=1
      6 )

File [~/miniconda3/envs/sc2_clone/lib/python3.11/site-packages/scranpy/aggregate_across_cells.py:106](http://localhost:8888/lab/tree/~/miniconda3/envs/sc2_clone/lib/python3.11/site-packages/scranpy/aggregate_across_cells.py#line=105), in aggregate_across_cells(x, factors, num_threads)
    103 comblev = biocutils.NamedList(comblev, facnames)
    105 mat = mattress.initialize(x)
--> 106 outsum, outdet = lib.aggregate_across_cells(mat.ptr, combind, num_threads)
    108 counts = numpy.zeros(len(comblev[0]), dtype=numpy.uint32)
    109 for i in combind:

RuntimeError: length of 'groups' should be equal to the number of columns in 'x'

but in my data,length of 'groups' is equal to the number of columns in 'x'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions