Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspershen committed May 17, 2023
1 parent 8b09e70 commit f09e4ce
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: masscleaner
Type: Package
Title: Data cleaning for LC-MS based metabolomics data
Version: 1.0.10
Version: 1.0.11
Date: 2023-05-16
Authors@R: c(person(given = "Xiaotao",
family = "Shen",
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,7 @@
# Version 1.0.10 (20230516)
--------------
* Fixed bug in normalize_data function.

# Version 1.0.10 (20230517)
--------------
* Fixed bug in normalize_data function.
5 changes: 5 additions & 0 deletions R/check_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ check_for_qc_normalization <-
sample_info <-
object@sample_info

###remove blank samples
sample_info <-
sample_info %>%
dplyr::filter(!is.na(injection.order))

purrr::map(
unique(sample_info$batch),
.f = function(batch_idx) {
Expand Down
21 changes: 18 additions & 3 deletions R/normalize_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ normalize_data <-
new_expression_data <-
normalize_data_total(x = expression_data, keep_scale = keep_scale)

object@expression_data <-
object@expression_data <-
as.data.frame(new_expression_data)

parameter <- new(
Expand All @@ -78,7 +78,7 @@ normalize_data <-
if (method == "mean") {
new_expression_data <-
normalize_data_mean(x = expression_data, keep_scale = keep_scale)
object@expression_data <-
object@expression_data <-
as.data.frame(new_expression_data)

parameter <- new(
Expand All @@ -94,7 +94,7 @@ normalize_data <-
if (method == "median") {
new_expression_data <-
normalize_data_median(x = expression_data, keep_scale = keep_scale)
object@expression_data <-
object@expression_data <-
as.data.frame(new_expression_data)

parameter <- new(
Expand Down Expand Up @@ -232,9 +232,24 @@ normalize_data <-
stop("No Subject in your sample_info column 'class'")
}

sample_info <-
sample_info %>%
dplyr::mutate(batch = as.character(batch))

sample_info$batch[sample_info$class != "QC" &
sample_info$class != "Subject"] <-
NA

sample_info$batch[is.na(sample_info$batch)] <- "NA"

data_nor <-
purrr::map(unique(sample_info$batch), function(batch_idx) {
message(crayon::yellow("Batch", batch_idx, "..."))
if (batch_idx == "NA") {
new_data <-
expression_data[, sample_info$batch == batch_idx]
return(new_data)
}
subject_id <-
sample_info %>%
dplyr::filter(class == "Subject" &
Expand Down

0 comments on commit f09e4ce

Please sign in to comment.