Skip to content

Commit

Permalink
Update the 03_SummarizedExperiment files after running tangle.R
Browse files Browse the repository at this point in the history
  • Loading branch information
lcolladotor committed Jul 3, 2023
1 parent c83d326 commit 75e6fa1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
38 changes: 32 additions & 6 deletions 03_SummarizedExperiment.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## ---- include = FALSE------------------------------------------------
## ---- include = FALSE--------------------------------------------
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
Expand All @@ -21,20 +21,20 @@ bib <- c(
options(max.print = 50)


## ---- echo=FALSE-----------------------------------------------------
## ---- echo=FALSE-------------------------------------------------
suppressPackageStartupMessages(library(SummarizedExperiment))
suppressPackageStartupMessages(data(airway, package = "airway"))


## --------------------------------------------------------------------
## ----------------------------------------------------------------
library(SummarizedExperiment)
library(airway)

data(airway, package = "airway")
se <- airway


## --------------------------------------------------------------------
## ----------------------------------------------------------------
## For a) you could only print the summary of the object but since the idea is to understand
## how to explore the object find other function that gives you the answer.
se
Expand All @@ -45,7 +45,7 @@ se
colData(se)


## --------------------------------------------------------------------
## ----------------------------------------------------------------
## In our object, if you look at the part that says assays, we can see that at the moment
## we only have one with the name "counts"

Expand Down Expand Up @@ -75,8 +75,34 @@ assayNames(se)
assayNames(se)[1] <- "counts"


## --------------------------------------------------------------------
## ----------------------------------------------------------------
## To calculate the library size use

apply(assay(se), 2, sum)


## ----------------------------------------------------------------
## For a), dim() gives the desired answer

dim(se)

## For b),

colData(se)[colData(se)$dex == "trt", ]


## ----------------------------------------------------------------
## There are multiple ways to do it

assay(se, "logcounts") <- log10(assay(se, "counts"))

assays(se)$logcounts_v2 <- log10(assays(se)$counts)


## ----------------------------------------------------------------
## To add the library size we an use..

colData(se)$library_size <- apply(assay(se), 2, sum)

names(colData(se))

2 changes: 1 addition & 1 deletion 03_SummarizedExperiment.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ font-family: sans-serif;
dim(se)
## For b),
## For b),
colData(se)[colData(se)$dex == "trt", ]
```
Expand Down

0 comments on commit 75e6fa1

Please sign in to comment.