Skip to content

Instantly share code, notes, and snippets.

@GuangchuangYu

GuangchuangYu/qbar.R

Last active Jan 9, 2018
Embed
What would you like to do?
qbar <- function(x, verbose=TRUE) {
enc = encoding(quality(x))
qual <- sapply(seq_along(x), function(i) enc[to_char_vector(x[i])])
mq <- rowMeans(qual)
if (verbose) {
names(mq) <- NULL
print(mq)
}
pillar:::spark_bar(mq/max(enc))
}
to_char_vector <- function(x) {
toString(x@quality@quality) %>% strsplit(split='') %>% unlist
}
require(ShortRead)
x <- readFastq(system.file('extdata/E-MTAB-1147/ERR127302_1_subset.fastq.gz', package='ShortRead'))
qbar(x[1:50])
@GuangchuangYu

This comment has been minimized.

Copy link
Owner Author

@GuangchuangYu GuangchuangYu commented Jun 2, 2017

> require(ShortRead)
> x <- readFastq(system.file('extdata/E-MTAB-1147/ERR127302_1_subset.fastq.gz', package='ShortRead'))
>
> qbar(x[1:50])
 [1] 38.76 38.42 38.36 37.92 37.78 38.20 37.92 38.56 38.28 38.22 37.98 38.08
[13] 38.12 37.94 38.12 38.34 37.86 37.96 38.26 37.98 37.12 36.36 36.70 36.28
[25] 36.92 36.98 36.78 37.04 36.44 36.66 36.44 36.44 36.36 36.46 36.90 35.86
[37] 36.30 36.22 35.76 36.14 35.60 35.70 34.88 34.34 35.28 35.82 35.46 34.70
[49] 34.52 34.08 33.74 33.88 33.24 34.16 33.38 33.44 32.44 34.00 32.86 33.88
[61] 33.72 33.48 33.12 32.98 31.32 32.00 32.58 30.82 31.12 29.62 29.28 27.76
▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.