Empty kernel in SEACells model
0
0
Entering edit mode
5 weeks ago
JACKY ▴ 150

I am following this tutorial for implementing SEACells and MC2 algorithms.

I run this code :

 adata = sc.read_h5ad('myData.h5ad')

raw_ad = sc.AnnData(adata.X)
raw_ad.obs_names, raw_ad.var_names = adata.obs_names, adata.var_names
adata.raw = raw_ad

# process data with SCANPY
# note that we don't scale the data matrix before PCA. this is how
# they do it in the SEACells tutorial so we do it that way here.
sc.pp.normalize_per_cell(adata)
sc.pp.log1p(adata)
sc.pp.highly_variable_genes(adata, n_top_genes=1500)
sc.tl.pca(adata, n_comps=50, use_highly_variable=True)

##################################################################################
# Running SEACells
##################################################################################

# they recommend one metacell for every 75 real cells
n_SEACells = int(np.floor(adata.obs.shape[0] / 75))

build_kernel_on = 'X_pca' # key in ad.obsm to use for computing metacells
                          # This would be replaced by 'X_svd' for ATAC data

## Additional parameters
n_waypoint_eigs = 10 # Number of eigenvalues to consider when initializing metacells
waypoint_proportion = 0.9 # Proportion of metacells to initialize using waypoint analysis,
                        # the remainder of cells are selected by greedy selection

# set up the model
model = SEACells.core.SEACells(adata,
                  build_kernel_on=build_kernel_on,
                  n_SEACells=n_SEACells,
                  n_waypoint_eigs=n_waypoint_eigs,
                  convergence_epsilon = 1e-5)

But model.K , the kernel, is empty. So, when I run the next line of code model.initialize_archetypes() this is what I get:

    236 """Initialize SEACells using fast greedy adaptive CSSP
    237 
    238 From https://arxiv.org/pdf/1312.6838.pdf
   (...)
    241 :return: B - (array) n_datapoints x n_SEACells matrix with initial SEACell definitions
    242 """
    244 K = self.K
--> 245 n = K.shape[0]
    247 if n_mcs is None:
    248     k = self.k

AttributeError: 'NoneType' object has no attribute 'shape'

How do I fix this? I did some testing, I checked if the PCA data is there, and it seems just fine :

if 'X_pca' in adata.obsm:
    print("PCA data is available.")
    print(adata.obsm['X_pca'].shape)
else:
    print("PCA data is missing.")


PCA data is available.
(258424, 50)
single-cell scanpy seacells python anndata • 112 views
ADD COMMENT

Login before adding your answer.

Traffic: 1476 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6