Skip to content

Commit 5b0bbcf

Browse files
authored
Merge pull request #10 from iibadshah/main
protools2 v0.2.15
2 parents ea8a527 + 585ea68 commit 5b0bbcf

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: protools2
22
Type: Package
33
Title: A Set Of Tools For Proteomics And Phosphoproteomics Data Analysis
4-
Version: 0.2.14
4+
Version: 0.2.15
55
Date: 2025-04-15
66
Authors@R: c(
77
person("Pedro", "Cutillas", , "p.cutillas@qmul.ac.uk", role = "aut",

R/script_helpers.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ impute_na <- function(df.design, df.areas) {
227227
# Select only numeric columns
228228
numeric_columns <- df.areas[, sapply(df.areas, is.numeric)]
229229

230+
# Set 0 as NA
231+
numeric_columns[numeric_columns == 0] <- NA
232+
230233
# Apply the min function to the dataset's numeric columns
231234
min_value <- min(numeric_columns, na.rm = TRUE)
232235

@@ -235,8 +238,8 @@ impute_na <- function(df.design, df.areas) {
235238
# Get the columns in df.areas that belong to the current condition
236239
cols <- df.design$heading[df.design$condition == condition]
237240

238-
# Calculate the mean of each row for the current condition, ignoring NA values
239-
row_means <- apply(df.areas[, cols], 1, function(x) if (all(is.na(x))) NA else mean(x, na.rm = TRUE))
241+
# Calculate the mean of each row for the current condition, ignoring NA values (`drop = FALSE` ensures that the result is still a data frame)
242+
row_means <- apply(df.areas[, cols, drop = FALSE], 1, function(x) if (all(is.na(x))) NA else mean(x, na.rm = TRUE))
240243

241244
# Replace NA values in df.areas for the current condition with the row means
242245
for (heading in cols) {

0 commit comments

Comments
 (0)