knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
Occasionally, we want to perform arithmetic operations on the values contained in 2 se's, for instance when subtracting control values from treated values.
If we want to subtract the values from time == 0 from the values at time == 4, this can
be achieved with a combination of filter
and -
.
Arithmetic operations require the se's to have the same ColData and rowData.
To ensure the colData is the same, we have to:
select
functionlibrary(dplyr) library(SummarizedExperiment) library(cleanse)
data(seq_se) seq_se_t0 <- seq_se %>% filter(col, time == 0) %>% select(col, -time) %>% arrange(col, patient, site, treatment) assay(seq_se_t0)[1:5, 1:5] seq_se_t4 <- seq_se %>% filter(col, time == 4) %>% select(col, -time) %>% arrange(col, patient, site, treatment) assay(seq_se_t4)[1:5, 1:5] seq_se_diff <- seq_se_t4 - seq_se_t0 assay(seq_se_diff)[1:5, 1:5]
Similarly, functions for +
, /
, and *
, can be used.
In addition, a method to round the values from all assays is provided:
seq_se_rounded <- seq_se %>% round(3) assay(seq_se)[1:5, 1:5] assay(seq_se_rounded)[1:5, 1:5]
sessionInfo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.