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

bc.st.clr_normalize() fails #367

Open
bhoellbacher opened this issue Nov 6, 2024 · 0 comments
Open

bc.st.clr_normalize() fails #367

bhoellbacher opened this issue Nov 6, 2024 · 0 comments

Comments

@bhoellbacher
Copy link

Running standard_workflow notebooks fails when running with CITEseq data

ValueError                                Traceback (most recent call last)
Cell In[38], line 30
     28 #perform normalization (this normalization is specific to CITEseq data)
     29 if adt_norm == 'CLR':
---> 30     bc.st.clr_normalize(adata_prot, os.path.join(results_folder_citeseq, 'citeseq'))
     32 #perform batch correction if desired otherwise just perform clustering
     33 if (batch_to_correct != 'None'):
     34     #save a copy of uncorrected in case we need it for something later

File .../lib/python3.9/site-packages/besca/st/_wrapper_funcs.py:290, in clr_normalize(adata, results_folder)
    285 start = time()
    287 # normalize per cell
    288 # this also already applies log! Is not taken seperately
    289 # already normalize BEFORE saving "raw" - as recommended in the scanpy tutorial
--> 290 normalize_geometric(adata)
    291 print("clr normalization applied to adata")
    293 # keep raw copy

File .../lib/python3.9/site-packages/besca/pp/_normalization.py:188, in normalize_geometric(adata)
    185 X = np.array(X)
    187 # replacement of zero values with very small numbers without changing the overall sums
--> 188 X = multiplicative_replacement(X)
    190 # centre log ratio transformation
    191 X = clr(X)

File .../lib/python3.9/site-packages/besca/pp/_normalization.py:132, in multiplicative_replacement(mat, delta)
     87 def multiplicative_replacement(mat, delta=None):
     88     r"""Replace all zeros with small non-zero values
     89     It uses the multiplicative replacement strategy [1]_ ,
     90     replacing zeros with a small positive :math:`\delta`
   (...)
    129            [0.0625, 0.4375, 0.4375, 0.0625]])
    130     """
--> 132     mat = closure(mat)
    133     z_mat = mat == 0
    135     num_feats = mat.shape[-1]

File .../lib/python3.9/site-packages/besca/pp/_normalization.py:37, in closure(mat)
      6 """
      7 Performs closure to ensure that all elements add up to 1.
      8 
   (...)
     34        [0.4, 0.4, 0.2]])
     35 """
     36 mat = np.atleast_2d(mat)
---> 37 if np.any(mat < 0):
     38     raise ValueError("Cannot have negative proportions")
     39 if mat.ndim > 2:

File .../lib/python3.9/site-packages/scipy/sparse/_base.py:396, in _spbase.__bool__(self)
    394     return self.nnz != 0
    395 else:
--> 396     raise ValueError("The truth value of an array with more than one "
    397                      "element is ambiguous. Use a.any() or a.all().")

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all().
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

1 participant