5.2 Custom seed matrices

By default, normpatch uses the bundled arab dataset, an Arabidopsis thaliana RNA-seq count matrix, to construct the population of mean and variance parameters used for simulation.

data(arab, package = "normpatch")
head(arab)
##           mock1 mock2 mock3 hrcc1 hrcc2 hrcc3
## AT1G01010    35    77    40    46    64    60
## AT1G01020    43    45    32    43    39    49
## AT1G01030    16    24    26    27    35    20
## AT1G01040    72    43    64    66    25    90
## AT1G01050    49    78    90    67    45    60
## AT1G01060     0    15     2     0    21     8

The sim_gene_counts() function can also use a user-supplied count matrix as the seed population for simulation. The example below uses the Arabidopsis count matrix stored in docs/data/ath.E-MTAB-4391.txt as the seed matrix.

seed_counts <- read.table("data/ath.E-MTAB-4391.txt", header = TRUE, sep = "\t", row.names = 1)
seed_counts <- as.matrix(seed_counts)
seed_counts <- rbind(seed_counts[, 1:3], seed_counts[, 4:6])
seed_counts <- seed_counts[rowSums(seed_counts) > 0, , drop = FALSE]
head(seed_counts)
##           control_1 control_2 control_3
## AT1G01010       558       457       392
## AT1G01020       442       345       274
## AT1G01030        33        27        21
## AT1G01040      1149       843       703
## AT1G01046        12        12        19
## AT1G01050      2013      1744      1585

The simulated count matrix can then be generated from this seed.

set.seed(1)

x <- sim_gene_counts(seed_counts = seed_counts, fc_mean = c(2, 2))
is_DEG <- def_DEG(x, fc = 2)

x <- calc_nf(x)

gene_colors <- ifelse(is_DEG, "#B24745", "#ADADAD")
plot_ma(x, col = gene_colors)