Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
myushen committed Nov 18, 2024
1 parent ac806de commit 2e4baf9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions R/tranform_assay.R
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,22 @@ transform_utility = function(input_read_RNA_assay, transform_fx, external_path,
# If the mode value is negative, shift counts and counts used for estimation to make the mode zero
if (mode_value < 0) {
counts <- counts + abs(mode_value)
counts_light_for_checks_shifted <- counts_light_for_checks + abs(mode_value)
}
counts_light_for_checks_apply_mode <- counts_light_for_checks + abs(mode_value)
} else {counts_light_for_checks_apply_mode <- counts_light_for_checks}

# Round counts to avoid potential subtraction errors due to floating-point precision
counts <- round(counts, 5)

# Find the most frequent count value (mode) in the counts
majority_gene_counts <- compute_mode_delayedarray(counts_light_for_checks_shifted)$mode
majority_gene_counts <- compute_mode_delayedarray(counts_light_for_checks_apply_mode)$mode

# Subtract the mode value from counts if it is not zero
if (majority_gene_counts != 0) {
counts <- counts - majority_gene_counts
}

# Replace negative counts with zero to avoid downstream failures.
# Use counts_light_for_checks here instead of the shifted value
# Use counts_light_for_checks here instead of the potential shifted value
if (min(counts_light_for_checks) < 0) {
counts[counts < 0] <- 0
}
Expand Down

0 comments on commit 2e4baf9

Please sign in to comment.