Skip to content

Differing shapes in sctransform_from_parameters #15

@Normann-BPh

Description

@Normann-BPh

Hello,

I've encountered a confusing error. As in, I don't think this should happen if the input has been processed thus far.

I run ComSeg via a script-version of your tutorial, with SRT Xenium data and Xenium cell masks.
After image-processing I receive ValueError: operands could not be broadcast together with shapes (93187,541) (93187,539) in sctransform_from_parameters, as you can see below.

Is this error caused by a wrong-package version or actually mismatching input?

The only other option I could imagine is, that something is changing self.anndata between passing fit_params, array_of_vect to sctransform_from_params and calculating param_sctransform from the count_matrix, but that sounds too convoluted to be the problem.

Hope you can help!

Kindest regards
n-bph

(ComSeg) [user]$ python scripts/seg_comseg.py
config dict overwritting default parameters
11693
prior added to transcripts_36_pixel_relative and saved in csv file
dict_centroid added for transcripts_36_pixel_relative
Processing images: 100%|████████████████████████████████████████| 1/1 [06:15<00:00, 375.49s/it]
100%|████████████████████████████████████████████████████████| 541/541 [02:01<00:00,  4.45it/s]
  0%|                                                                    | 0/1 [00:00<?, ?it/s]improvement of modularity 0.006270115694725686
improvement of modularity 0.00036438836270757946
improvement of modularity 2.210827103554802e-05
improvement of modularity 2.3542855431823995e-07
stop because of improvement of modularity 5.517261314480493e-09  below  the threshold  1e-07
100%|██████████████████████████████████████████████████████████| 1/1 [22:26<00:00, 1346.10s/it]
Writing temporary files...
Running scTransform via Rscript...

Attaching package: arrow

The following objects are masked from package:feather:

    read_feather, write_feather

The following object is masked from package:utils:

    timestamp

Calculating cell attributes from input UMI matrix: log_umi
Variance stabilizing transformation of count matrix of size 539 by 10000
Model formula is y ~ log_umi
Get Negative Binomial regression parameters per gene
Using 539 genes, 10000 cells
  |======================================================================| 100%
Found 12 outliers - those will be ignored in fitting/regularization step

Second step: Get residuals using fitted parameters for 539 genes
  |======================================================================| 100%
Calculating gene attributes
Wall clock passed: Time difference of 16.19295 secs
Reading output files...
Clipping residuals...
user/micromamba/envs/ComSeg/lib/python3.8/site-packages/comseg/utils/preprocessing.py:59: RuntimeWarning: divide by zero encountered in log10
  regressor_data[:, 1] = np.log10(np.sum(array_of_vect, axis=1))
Traceback (most recent call last):
  File "scripts/seg_comseg.py", line 69, in <module>
    Comsegdict.run_all(
  File "user/micromamba/envs/ComSeg/lib/python3.8/site-packages/comseg/dictionary.py", line 580, in run_all
    self.compute_insitu_clustering(
  File "user/micromamba/envs/ComSeg/lib/python3.8/site-packages/comseg/dictionary.py", line 258, in compute_insitu_clustering
    self.global_anndata = self.in_situ_clustering.cluster_rna_community(
  File "user/micromamba/envs/ComSeg/lib/python3.8/site-packages/comseg/clustering.py", line 138, in cluster_rna_community
    count_matrix_anndata = sctransform_from_parameters(self.param_sctransform,
  File "user/micromamba/envs/ComSeg/lib/python3.8/site-packages/comseg/utils/preprocessing.py", line 63, in sctransform_from_parameters
    res = (array_of_vect - mu) / np.sqrt(mu + mu ** 2 / fit_params[0, :])
ValueError: operands could not be broadcast together with shapes (93187,541) (93187,539)

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