Skip to content

Commit 8af2119

Browse files
committed
patch bug to remove Original_ID if it wasn't there in the first place
1 parent 6d5550f commit 8af2119

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/methods/batchadjust_all_controls/script.R

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ library(flowCore)
33
## VIASH START
44
par <- list(
55
input = "resources_test/debug/batchadjust/_viash_par/input_1/censored_split1.h5ad",
6-
output = "output.h5ad",
6+
output = "resources_test/debug/batchadjust/output.h5ad",
77
percentile = as.integer('80')
88
)
99
meta <- list(
1010
name = "batchadjust_all_controls",
11-
temp_dir = "/tmp"
11+
temp_dir = "/tmp",
12+
resources_dir = "src/methods/batchadjust_all_controls"
1213
)
14+
source("src/utils/anndata_to_fcs.R")
1315
## VIASH END
1416

1517
source(paste0(meta$resources_dir, "/utils.R"))
@@ -37,6 +39,8 @@ input <- anndata::read_h5ad(par[["input"]])
3739
#use Original_ID column to restore cell order after I/O operations
3840
# input$layers["preprocessed"][, "Original_ID"] <- seq(1, dim(input)[1])
3941

42+
original_id_in_var <- "Original_ID" %in% input$var_names
43+
4044
input <- add_original_id(input)
4145

4246
cat("Split cells\n")
@@ -105,6 +109,11 @@ if (FALSE %in% order_check) {
105109
stop("Failed in restoring indexing")
106110
}
107111

112+
# Remove Original_ID if it was not there in the beginning
113+
if (!original_id_in_var) {
114+
corrected_matrix$Original_ID <- NULL
115+
}
116+
108117
cat("Write output AnnData to file\n")
109118
output <- anndata::AnnData(
110119
obs = input$obs[, integer(0)],

src/methods/batchadjust_one_control/script.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ input <- anndata::read_h5ad(par[["input"]])
3838
#use Original_ID column to restore cell order after I/O operations
3939
# input$layers["preprocessed"][, "Original_ID"] <- seq(1, dim(input)[1])
4040

41+
original_id_in_var <- "Original_ID" %in% input$var_names
42+
4143
input <- add_original_id(input)
4244

4345
cat("Split cells\n")
@@ -105,6 +107,11 @@ if (FALSE %in% order_check) {
105107
stop("Failed in restoring indexing")
106108
}
107109

110+
# Remove Original_ID if it was not there in the beginning
111+
if (!original_id_in_var) {
112+
corrected_matrix$Original_ID <- NULL
113+
}
114+
108115
cat("Write output AnnData to file\n")
109116
output <- anndata::AnnData(
110117
obs = input$obs[, integer(0)],

0 commit comments

Comments
 (0)