Skip to content

Commit 6e8ed0b

Browse files
Backport PR #678 to 0.10.x (#684)
* log1p: fix input layer argument being unused. (#678) * log1p: fix input layer argument being unused. * Add CHANGELOG entry * Remove target folder * Update CI * deploy: e7a3192 * Revert "Update CI" This reverts commit e7a3192. --------- Co-authored-by: DriesSchaumont <[email protected]>
1 parent 8051bd4 commit 6e8ed0b

File tree

481 files changed

+13661
-8655
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

481 files changed

+13661
-8655
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# openpipelines 0.10.2
2+
3+
## BUG FIXES
4+
5+
* `transform/log1p`: fix `--input_layer` argument not functionning (PR #678).
6+
17
# openpipelines 0.10.1
28

39
## MINOR CHANGES

src/transform/log1p/run_test.py

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,58 @@
11
from os import path
22
import mudata as mu
33
import numpy as np
4+
import scanpy as sc
5+
import pandas as pd
46
import sys
57
import pytest
68
import sys
9+
import uuid
710
from operator import attrgetter
811

912
## VIASH START
1013
meta = {
1114
'functionality_name': 'lognorm',
1215
'resources_dir': 'resources_test/',
13-
'config': '/home/di/code/openpipeline/src/transform/log1p/config.vsh.yaml',
16+
'config': './src/transform/log1p/config.vsh.yaml',
1417
'executable': "../../target/docker/transform/log1p/log1p"
1518
}
1619

1720

1821
## VIASH END
1922

2023
@pytest.fixture
21-
def input_path():
22-
return f"{meta['resources_dir']}/pbmc_1k_protein_v3/pbmc_1k_protein_v3_filtered_feature_bc_matrix.h5mu"
24+
def input_data():
25+
return mu.read_h5mu(f"{meta['resources_dir']}/pbmc_1k_protein_v3/pbmc_1k_protein_v3_filtered_feature_bc_matrix.h5mu").copy()
26+
27+
@pytest.fixture
28+
def random_h5mu_path(tmp_path):
29+
def wrapper():
30+
unique_filename = f"{str(uuid.uuid4())}.h5mu"
31+
temp_file = tmp_path / unique_filename
32+
return temp_file
33+
return wrapper
2334

2435
@pytest.mark.parametrize("output_layer", [None, "log_normalized"])
25-
def test_1logp(run_component, input_path, output_layer):
26-
output = "output.h5mu"
36+
@pytest.mark.parametrize("input_layer", [None, "normalized"])
37+
def test_1logp(run_component, input_data, output_layer, input_layer, random_h5mu_path):
38+
output = random_h5mu_path()
39+
if input_layer:
40+
mod = input_data.mod["rna"]
41+
mod.layers[input_layer] = mod.X.copy()
42+
# Overwrite the original layer to make sure
43+
# it is not accidentally used as input layer.
44+
mod.X[:] = 0
45+
input_path = random_h5mu_path()
46+
input_data.write(input_path)
2747
run_args = [
2848
"--input", input_path,
2949
"--output", output,
3050
"--output_compresion", "gzip"
3151
]
3252
if output_layer:
3353
run_args.extend(["--output_layer", output_layer])
54+
if input_layer:
55+
run_args.extend(["--input_layer", input_layer])
3456
run_component(run_args)
3557
get_output_layer = attrgetter("X") if not output_layer else lambda x: getattr(x, 'layers')[output_layer]
3658

@@ -49,16 +71,31 @@ def test_1logp(run_component, input_path, output_layer):
4971

5072
assert rna_in.shape == rna_out.shape, "Should have same shape as before"
5173
assert prot_in.shape == prot_out.shape, "Should have same shape as before"
74+
input_layer_data = rna_in.X if not input_layer else rna_in.layers[input_layer]
75+
assert np.mean(input_layer_data) != np.mean(get_output_layer(rna_out)), "Expression should have changed"
5276

53-
assert np.mean(rna_in.X) != np.mean(get_output_layer(rna_out)), "Expression should have changed"
54-
55-
nz_row, nz_col = rna_in.X.nonzero()
56-
row_corr = np.corrcoef(rna_in.X[nz_row[0],:].toarray().flatten(), get_output_layer(rna_out)[nz_row[0],:].toarray().flatten())[0,1]
57-
col_corr = np.corrcoef(rna_in.X[:,nz_col[0]].toarray().flatten(), get_output_layer(rna_out)[:,nz_col[0]].toarray().flatten())[0,1]
77+
nz_row, nz_col = input_layer_data.nonzero()
78+
row_corr = np.corrcoef(input_layer_data[nz_row[0],:].toarray().flatten(),
79+
get_output_layer(rna_out)[nz_row[0],:].toarray().flatten())[0,1]
80+
col_corr = np.corrcoef(input_layer_data[:,nz_col[0]].toarray().flatten(),
81+
get_output_layer(rna_out)[:,nz_col[0]].toarray().flatten())[0,1]
5882
assert row_corr > .1
5983
assert col_corr > .1
6084

6185
assert 'log1p' in rna_out.uns
6286

87+
# Make sure that the original input layer has not been overwritten
88+
layers_to_test = [None] + list(rna_in.layers.keys())
89+
for layer in layers_to_test:
90+
if layer != output_layer:
91+
in_data = sc.get.var_df(rna_in,
92+
keys=rna_in.obs_names.to_list(),
93+
layer=layer)
94+
out_data = sc.get.var_df(rna_out,
95+
keys=rna_in.obs_names.to_list(),
96+
layer=layer)
97+
pd.testing.assert_frame_equal(in_data, out_data)
98+
99+
63100
if __name__ == '__main__':
64101
sys.exit(pytest.main([__file__]))

src/transform/log1p/script.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import scanpy as sc
22
import mudata as mu
3+
import anndata as ad
34
import sys
45

56
## VIASH START
@@ -39,12 +40,24 @@ def setup_logger():
3940
mod = par["modality"]
4041
logger.info("Performing log transformation on modality %s", mod)
4142
data = mdata.mod[mod]
42-
new_layer = sc.pp.log1p(data,
43-
base=par["base"],
44-
copy=True if par['output_layer'] else False)
45-
if new_layer:
46-
data.layers[par['output_layer']] = new_layer.X
47-
data.uns['log1p'] = new_layer.uns['log1p']
43+
44+
# Make our own copy with not a lot of data
45+
# this avoid excessive memory usage and accidental overwrites
46+
input_layer = data.layers[par["input_layer"]] \
47+
if par["input_layer"] else data.X
48+
data_for_scanpy = ad.AnnData(X=input_layer.copy())
49+
sc.pp.log1p(data_for_scanpy,
50+
base=par["base"],
51+
layer=None, # use X
52+
copy=False) # allow overwrites in the copy that was made
53+
54+
# Scanpy will overwrite the input layer.
55+
# So fetch input layer from the copy and use it to populate the output slot
56+
if par["output_layer"]:
57+
data.layers[par["output_layer"]] = data_for_scanpy.X
58+
else:
59+
data.X = data_for_scanpy.X
60+
data.uns['log1p'] = data_for_scanpy.uns['log1p'].copy()
4861

4962
logger.info("Writing to file %s", par["output"])
5063
mdata.write_h5mu(filename=par["output"], compression=par["output_compression"])

target/docker/annotate/popv/.config.vsh.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
functionality:
22
name: "popv"
33
namespace: "annotate"
4-
version: "0.10.1"
4+
version: "0.10.2"
55
authors:
66
- name: "Matthias Beyens"
77
roles:
@@ -247,6 +247,7 @@ platforms:
247247
image: "python:3.9-slim"
248248
target_organization: "openpipelines-bio"
249249
target_registry: "ghcr.io"
250+
target_tag: "0.10.1"
250251
namespace_separator: "_"
251252
resolve_volume: "Automatic"
252253
chown: true
@@ -343,5 +344,6 @@ info:
343344
output: "/home/runner/work/openpipeline/openpipeline/target/docker/annotate/popv"
344345
executable: "/home/runner/work/openpipeline/openpipeline/target/docker/annotate/popv/popv"
345346
viash_version: "0.7.5"
346-
git_commit: "3d2a0f21b49b7c8bc40e44e668191f0a8cb784b5"
347+
git_commit: "e7a31922173ed91fb3a087194dd899bae2698824"
347348
git_remote: "https://github.com/openpipelines-bio/openpipeline"
349+
git_tag: "0.10.1-3-ge7a3192217"

target/docker/annotate/popv/popv

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
# popv 0.10.1
3+
# popv 0.10.2
44
#
55
# This wrapper script is auto-generated by viash 0.7.5 and is thus a derivative
66
# work thereof. This software comes with ABSOLUTELY NO WARRANTY from Data
@@ -159,7 +159,7 @@ VIASH_META_TEMP_DIR="$VIASH_TEMP"
159159

160160
# ViashHelp: Display helpful explanation about this executable
161161
function ViashHelp {
162-
echo "popv 0.10.1"
162+
echo "popv 0.10.2"
163163
echo ""
164164
echo "Performs popular major vote cell typing on single cell sequence data using"
165165
echo "multiple algorithms. Note that this is a one-shot version of PopV."
@@ -491,10 +491,10 @@ RUN pip install --upgrade pip && \
491491
492492
LABEL org.opencontainers.image.authors="Matthias Beyens, Robrecht Cannoodt"
493493
LABEL org.opencontainers.image.description="Companion container for running component annotate popv"
494-
LABEL org.opencontainers.image.created="2023-09-08T15:50:22Z"
494+
LABEL org.opencontainers.image.created="2024-01-31T12:04:47Z"
495495
LABEL org.opencontainers.image.source="https://github.com/openpipelines-bio/openpipeline"
496-
LABEL org.opencontainers.image.revision="3d2a0f21b49b7c8bc40e44e668191f0a8cb784b5"
497-
LABEL org.opencontainers.image.version="0.10.1"
496+
LABEL org.opencontainers.image.revision="e7a31922173ed91fb3a087194dd899bae2698824"
497+
LABEL org.opencontainers.image.version="0.10.2"
498498
499499
VIASHDOCKER
500500
}
@@ -645,7 +645,7 @@ while [[ $# -gt 0 ]]; do
645645
shift 1
646646
;;
647647
--version)
648-
echo "popv 0.10.1"
648+
echo "popv 0.10.2"
649649
exit
650650
;;
651651
--input)

target/docker/cluster/leiden/.config.vsh.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
functionality:
22
name: "leiden"
33
namespace: "cluster"
4-
version: "0.10.1"
4+
version: "0.10.2"
55
authors:
66
- name: "Dries De Maeyer"
77
roles:
@@ -140,6 +140,7 @@ platforms:
140140
image: "python:3.8-slim"
141141
target_organization: "openpipelines-bio"
142142
target_registry: "ghcr.io"
143+
target_tag: "0.10.1"
143144
namespace_separator: "_"
144145
resolve_volume: "Automatic"
145146
chown: true
@@ -213,5 +214,6 @@ info:
213214
output: "/home/runner/work/openpipeline/openpipeline/target/docker/cluster/leiden"
214215
executable: "/home/runner/work/openpipeline/openpipeline/target/docker/cluster/leiden/leiden"
215216
viash_version: "0.7.5"
216-
git_commit: "3d2a0f21b49b7c8bc40e44e668191f0a8cb784b5"
217+
git_commit: "e7a31922173ed91fb3a087194dd899bae2698824"
217218
git_remote: "https://github.com/openpipelines-bio/openpipeline"
219+
git_tag: "0.10.1-3-ge7a3192217"

target/docker/cluster/leiden/leiden

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
# leiden 0.10.1
3+
# leiden 0.10.2
44
#
55
# This wrapper script is auto-generated by viash 0.7.5 and is thus a derivative
66
# work thereof. This software comes with ABSOLUTELY NO WARRANTY from Data
@@ -158,7 +158,7 @@ VIASH_META_TEMP_DIR="$VIASH_TEMP"
158158

159159
# ViashHelp: Display helpful explanation about this executable
160160
function ViashHelp {
161-
echo "leiden 0.10.1"
161+
echo "leiden 0.10.2"
162162
echo ""
163163
echo "Cluster cells using the Leiden algorithm [Traag18] implemented in the Scanpy"
164164
echo "framework [Wolf18]."
@@ -445,10 +445,10 @@ RUN pip install --upgrade pip && \
445445
446446
LABEL org.opencontainers.image.authors="Dries De Maeyer"
447447
LABEL org.opencontainers.image.description="Companion container for running component cluster leiden"
448-
LABEL org.opencontainers.image.created="2023-09-08T15:50:25Z"
448+
LABEL org.opencontainers.image.created="2024-01-31T12:04:45Z"
449449
LABEL org.opencontainers.image.source="https://github.com/openpipelines-bio/openpipeline"
450-
LABEL org.opencontainers.image.revision="3d2a0f21b49b7c8bc40e44e668191f0a8cb784b5"
451-
LABEL org.opencontainers.image.version="0.10.1"
450+
LABEL org.opencontainers.image.revision="e7a31922173ed91fb3a087194dd899bae2698824"
451+
LABEL org.opencontainers.image.version="0.10.2"
452452
453453
VIASHDOCKER
454454
}
@@ -599,7 +599,7 @@ while [[ $# -gt 0 ]]; do
599599
shift 1
600600
;;
601601
--version)
602-
echo "leiden 0.10.1"
602+
echo "leiden 0.10.2"
603603
exit
604604
;;
605605
--input)

target/docker/compression/compress_h5mu/.config.vsh.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
functionality:
22
name: "compress_h5mu"
33
namespace: "compression"
4-
version: "0.10.1"
4+
version: "0.10.2"
55
authors:
66
- name: "Dries Schaumont"
77
roles:
@@ -83,6 +83,7 @@ platforms:
8383
image: "python:3.10-slim"
8484
target_organization: "openpipelines-bio"
8585
target_registry: "ghcr.io"
86+
target_tag: "0.10.1"
8687
namespace_separator: "_"
8788
resolve_volume: "Automatic"
8889
chown: true
@@ -161,5 +162,6 @@ info:
161162
output: "/home/runner/work/openpipeline/openpipeline/target/docker/compression/compress_h5mu"
162163
executable: "/home/runner/work/openpipeline/openpipeline/target/docker/compression/compress_h5mu/compress_h5mu"
163164
viash_version: "0.7.5"
164-
git_commit: "3d2a0f21b49b7c8bc40e44e668191f0a8cb784b5"
165+
git_commit: "e7a31922173ed91fb3a087194dd899bae2698824"
165166
git_remote: "https://github.com/openpipelines-bio/openpipeline"
167+
git_tag: "0.10.1-3-ge7a3192217"

target/docker/compression/compress_h5mu/compress_h5mu

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
# compress_h5mu 0.10.1
3+
# compress_h5mu 0.10.2
44
#
55
# This wrapper script is auto-generated by viash 0.7.5 and is thus a derivative
66
# work thereof. This software comes with ABSOLUTELY NO WARRANTY from Data
@@ -158,7 +158,7 @@ VIASH_META_TEMP_DIR="$VIASH_TEMP"
158158

159159
# ViashHelp: Display helpful explanation about this executable
160160
function ViashHelp {
161-
echo "compress_h5mu 0.10.1"
161+
echo "compress_h5mu 0.10.2"
162162
echo ""
163163
echo "Compress a MuData file."
164164
echo ""
@@ -408,10 +408,10 @@ RUN pip install --upgrade pip && \
408408
409409
LABEL org.opencontainers.image.authors="Dries Schaumont"
410410
LABEL org.opencontainers.image.description="Companion container for running component compression compress_h5mu"
411-
LABEL org.opencontainers.image.created="2023-09-08T15:50:23Z"
411+
LABEL org.opencontainers.image.created="2024-01-31T12:04:46Z"
412412
LABEL org.opencontainers.image.source="https://github.com/openpipelines-bio/openpipeline"
413-
LABEL org.opencontainers.image.revision="3d2a0f21b49b7c8bc40e44e668191f0a8cb784b5"
414-
LABEL org.opencontainers.image.version="0.10.1"
413+
LABEL org.opencontainers.image.revision="e7a31922173ed91fb3a087194dd899bae2698824"
414+
LABEL org.opencontainers.image.version="0.10.2"
415415
416416
VIASHDOCKER
417417
}
@@ -562,7 +562,7 @@ while [[ $# -gt 0 ]]; do
562562
shift 1
563563
;;
564564
--version)
565-
echo "compress_h5mu 0.10.1"
565+
echo "compress_h5mu 0.10.2"
566566
exit
567567
;;
568568
--input)

target/docker/compression/tar_extract/.config.vsh.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
functionality:
22
name: "tar_extract"
33
namespace: "compression"
4-
version: "0.10.1"
4+
version: "0.10.2"
55
arguments:
66
- type: "file"
77
name: "--input"
@@ -87,6 +87,7 @@ platforms:
8787
image: "ubuntu:latest"
8888
target_organization: "openpipelines-bio"
8989
target_registry: "ghcr.io"
90+
target_tag: "0.10.1"
9091
namespace_separator: "_"
9192
resolve_volume: "Automatic"
9293
chown: true
@@ -100,5 +101,6 @@ info:
100101
output: "/home/runner/work/openpipeline/openpipeline/target/docker/compression/tar_extract"
101102
executable: "/home/runner/work/openpipeline/openpipeline/target/docker/compression/tar_extract/tar_extract"
102103
viash_version: "0.7.5"
103-
git_commit: "3d2a0f21b49b7c8bc40e44e668191f0a8cb784b5"
104+
git_commit: "e7a31922173ed91fb3a087194dd899bae2698824"
104105
git_remote: "https://github.com/openpipelines-bio/openpipeline"
106+
git_tag: "0.10.1-3-ge7a3192217"

0 commit comments

Comments
 (0)