Skip to content

GlmpcaError: for count data, the minimum value must be >=0 #13

@ondina-draia

Description

@ondina-draia

Hello,

I'm trying to run PASTE2 to align two MERFISH slices but an error occured:

GlmpcaError Traceback (most recent call last)
Cell In[34], line 1
----> 1 pi_12 = PASTE2.partial_pairwise_align(slice_wt1_D, slice_wt2_D, s=0.7)

File ~/Documents/merfish_lames/p30/analysis/tutorials/stagate_base_2/lib/python3.9/site-packages/paste2/PASTE2.py:260, in partial_pairwise_align(sliceA, sliceB, s, alpha, armijo, dissimilarity, use_rep, G_init, a_distribution, b_distribution, norm, return_obj, verbose)
258 M = pca_distance(sliceA, sliceB, 2000, 20)
259 elif dissimilarity.lower() == 'glmpca':
--> 260 M = glmpca_distance(A_X, B_X, latent_dim=50, filter=True, verbose=verbose)
261 else:
262 print("ERROR")

File ~/Documents/merfish_lames/p30/analysis/tutorials/stagate_base_2/lib/python3.9/site-packages/paste2/helper.py:82, in glmpca_distance(X, Y, latent_dim, filter, verbose)
79 joint_matrix = joint_matrix[:, top_indices]
81 print("Starting GLM-PCA...")
---> 82 res = glmpca(joint_matrix.T, latent_dim, penalty=1, verbose=verbose)
83 #res = glmpca(joint_matrix.T, latent_dim, fam='nb', penalty=1, verbose=True)
84 reduced_joint_matrix = res["factors"]

File ~/Documents/merfish_lames/p30/analysis/tutorials/stagate_base_2/lib/python3.9/site-packages/paste2/glmpca.py:325, in glmpca(Y, L, fam, ctl, penalty, verbose, init, nb_theta, X, Z, sz)
323 # sanity check inputs
324 if fam in ("poi", "nb", "mult", "bern") and np.min(Y) < 0:
--> 325 raise GlmpcaError("for count data, the minimum value must be >=0")
326 if fam == "bern" and np.max(Y) > 1:
327 raise GlmpcaError("for Bernoulli model, the maximum value must be <=1")

GlmpcaError: for count data, the minimum value must be >=0

When running: pi_12 = PASTE2.partial_pairwise_align(slice_wt1_D, slice_wt2_D, s=0.7)

My data looks like this in terms of structure:

AnnData object with n_obs × n_vars = 21284 × 960 obs: 'fov', 'volume', 'center_x', 'center_y', 'min_x', 'min_y', 'max_x', 'max_y', 'anisotropy', 'transcript_count', 'perimeter_area_ratio', 'solidity', 'region', 'slide', 'dataset_id', 'cells_region', 'EntityID' var: 'mean', 'std' uns: 'log1p', 'spatialdata_attrs' obsm: 'blank', 'spatial'

My minimum transcript counts by gene is 20 (I don't know if it's relevant)

Image

Those are my slices.

What should I do? Where is the error coming from?

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