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

Error in detect_tissue: setting an array element with a sequence #125

Open
QuinceyLv opened this issue Oct 28, 2024 · 2 comments
Open

Error in detect_tissue: setting an array element with a sequence #125

QuinceyLv opened this issue Oct 28, 2024 · 2 comments

Comments

@QuinceyLv
Copy link

Hi,
Thanks for the great package.
I was running spacemake with visium data, and got an exception:

rule run_automated_analysis:
input: projects/visium_demo/processed_data/DSG_Control/illumina/complete_data/dge/dge.exon.polyA_adapter_trimmed.mm_included.spatial_beads_visium.h5ad
output: projects/visium_demo/processed_data/DSG_Control/illumina/complete_data/automated_analysis/visium/umi_cutoff_1000/DSG_Control_visium_results.h5ad
jobid: 47
wildcards: project_id=visium_demo, sample_id=DSG_Control, data_root_type=complete_data, downsampling_percentage=, run_mode=visium, umi_cutoff=1000, puck_barcode_file_id_qc=visium

Rscript --vanilla -e 'rmarkdown::render("/fakepath/openst_test_20240924/result/spacemake_20241021/.snakemake/scripts/tmpd9cfk6th.qc_sequencing_create_sheet.Rmd", output_file="/fakepath/openst_test_20240924/result/spacemake_20241021/projects/visium_demo/processed_data/DSG_Control/illumina/complete_data/qc_sheets/qc_sheet_DSG_Control_visium.html", quiet=TRUE, knit_root_dir = "/fakepath/openst_test_20240924/result/spacemake_20241021", params = list(rmd="/fakepath/openst_test_20240924/result/spacemake_20241021/.snakemake/scripts/tmpd9cfk6th.qc_sequencing_create_sheet.Rmd"))'
/fakepath/software/miniconda3/envs/spacemake/bin/python3.10 /fakepath/openst_test_20240924/result/spacemake_20241021/.snakemake/scripts/tmprifp4gew.automated_analysis.py

Finished job 61.
22 of 39 steps (56%) done
Traceback (most recent call last):
File "/fakepath/openst_test_20240924/result/spacemake_20241021/.snakemake/scripts/tmprifp4gew.automated_analysis.py", line 19, in
adata = detect_tissue(adata, umi_cutoff)
File "/fakepath/software/miniconda3/envs/spacemake/lib/python3.10/site-packages/spacemake/spatial/util.py", line 139, in detect_tissue
tissue_islands = np.delete(islands, np.argmax(island_sizes))
File "/fakepath/software/miniconda3/envs/spacemake/lib/python3.10/site-packages/numpy/lib/function_base.py", line 5245, in delete
arr = asarray(arr)
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (39,) + inhomogeneous part.

Then I checked the code in spacemake.spatial.utils.detect_tissue:

tissue_islands = np.delete(islands, np.argmax(island_sizes))

ChatGPT says this should be:

islands_array = np.array(islands, dtype=object)
max_index = np.argmax(island_sizes)
tissue_islands = np.delete(islands_array, max_index)
tissue_islands = tissue_islands.tolist()

I'm using spacemake 0.7.9 with numpy 1.26.4. Is that correct? Thanks in advance.

@nukappa
Copy link
Member

nukappa commented Oct 31, 2024

Hi there, thanks for reporting this.

We haven't been using this functionality in a while. Did you try implementing the correction you mentioned above and see if it works?

@QuinceyLv
Copy link
Author

Hi there, thanks for reporting this.

We haven't been using this functionality in a while. Did you try implementing the correction you mentioned above and see if it works?

Yes, it worked.

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

2 participants