Skip to content

Commit c41cc18

Browse files
committed
shorten code of data$read()
1 parent 8ae264f commit c41cc18

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

R/data_helpers.R

+5-11
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,19 @@ data_initialize <- function(self, private, name, directory, pivot_time_cutoff,
3535
}
3636

3737
data_read <- function(self, private){
38-
# extract values from self
39-
directory <- self$directory
40-
expr_file <- self$expr_file
41-
pheno_file <- self$pheno_file
42-
patient_id_col <- self$patient_id_col
43-
gene_id_col <- self$gene_id_col
44-
4538
# read
46-
self$pheno_tbl <- readr::read_csv(file.path(directory, pheno_file), show_col_types = FALSE)
47-
expr_tbl <- readr::read_csv(file.path(directory, expr_file), show_col_types = FALSE)
39+
self$pheno_tbl <- readr::read_csv(file.path(self$directory, self$pheno_file),
40+
show_col_types = FALSE)
41+
expr_tbl <- readr::read_csv(file.path(self$directory, self$expr_file), show_col_types = FALSE)
4842

4943
self$qc_preprocess(expr_tbl = expr_tbl)
5044

5145
# expression to matrix
5246
expr_mat <- expr_tbl |>
53-
dplyr::select(!dplyr::all_of(gene_id_col)) |>
47+
dplyr::select(!dplyr::all_of(self$gene_id_col)) |>
5448
as.matrix() |>
5549
t()
56-
colnames(expr_mat) <- expr_tbl[[gene_id_col]]
50+
colnames(expr_mat) <- expr_tbl[[self$gene_id_col]]
5751
self$expr_mat <- expr_mat
5852

5953
invisible(self)

0 commit comments

Comments
 (0)