Calculate splicing diversity changes between two conditions.
Source:R/difference_functions.R
calculate_fc.RdCalculate splicing diversity changes between two conditions.
Arguments
- x
A
matrixwith the splicing diversity values.- samples
Character vector with an equal length to the number of columns in the input dataset, specifying the category of each sample.
- control
Name of the control sample category, defined in the
samplesvector, e.g.control = 'Normal'orcontrol = 'WT'.- method
Method to use for calculating the average splicing diversity value in a condition. Can be
'mean'or'median'.- pseudocount
Numeric scalar. Small value added to non-positive observed group summaries to avoid zeros when computing differences and log2 fold-changes. If
pseudocount <= 0the function will automatically choose a scale-aware value equal to half the smallest positive observed group summary (i.e. half the smallest observed mean/median across groups); if no positive values are present the fallback is1e-6. Rows with insufficient observations remainNAand are not imputed.
Value
A data.frame with mean or median value of splicing diversity
across sample categories, the difference between these values and the log2
fold change values.
Details
The function uses a matrix of splicing diversity values in order to calculate mean or median differences and log2 fold changes between two conditions.
Examples
# Simulate splicing diversity matrix (4 genes x 4 samples)
mat <- matrix(c(
0.5, 0.6, 0.8, 0.9, # gene1: low control, high treatment
0.7, 0.75, 0.6, 0.5 # gene2: high control, low treatment
), nrow = 2, byrow = TRUE)
samples <- c('Normal', 'Normal', 'Tumor', 'Tumor')
result <- calculate_fc(mat, samples, control = 'Normal', method = 'mean')
head(result)
#> Tumor_mean Normal_mean mean_difference log2_fold_change
#> V1 0.85 0.550 0.300 0.6280312
#> V2 0.55 0.725 -0.175 -0.3985494