Skip to content

Commit

Permalink
Changes made during the morning to explore the data a bit more and un…
Browse files Browse the repository at this point in the history
…derstand the %in% R operator
  • Loading branch information
lcolladotor committed Mar 26, 2020
1 parent 38f8dd5 commit 2740c7f
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions R/03-quality-control.R
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ sce.grun <- addPerCellQC(sce.grun)

plotColData(sce.grun, x = "donor", y = "altexps_ERCC_percent")

hist(sce.grun$altexps_ERCC_percent[sce.grun$donor == 'D10'],
breaks = 100,
col = 'light blue')

hist(sce.grun$altexps_ERCC_percent[sce.grun$donor == 'D2'],
breaks = 100,
col = 'light blue')

discard.ercc <- isOutlier(sce.grun$altexps_ERCC_percent,
type = "higher",
batch = sce.grun$donor)
Expand All @@ -168,6 +176,27 @@ discard.ercc2 <- isOutlier(
subset = sce.grun$donor %in% c("D17", "D2", "D7")
)

## Understanding %in%
class(sce.grun$donor)
length(sce.grun$donor)
dim(sce.grun)
table(sce.grun$donor)

manual_subset <- sce.grun$donor == 'D17' | sce.grun$donor == 'D2' | sce.grun$donor == 'D7'
class(manual_subset)
length(manual_subset)
sum(manual_subset)
480 + 96 + 384

## quicker
# x %in% y
x <- c('a', 'b', 'c', 'ch')
y <- letters
x %in% y
x[x %in% y]
auto_subset <- sce.grun$donor %in% c('D17', 'D2', 'D7')
identical(manual_subset, auto_subset)

plotColData(
sce.grun,
x = "donor",
Expand Down

0 comments on commit 2740c7f

Please sign in to comment.