Created
July 17, 2020 13:28
-
-
Save simon-anders/b09bd19cda3900318e21b04f90bd0512 to your computer and use it in GitHub Desktop.
seegene_curves.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library( tidyverse ) | |
readRDS("~/sds/sd17l002/p/covidTests/data/allCurvesSeegene.rds") %>% ungroup() -> tbl | |
readRDS("~/sds/sd17l002/p/covidTests/data/testResults.rds" ) -> testres | |
tbl %>% pull( plateId ) %>% unique() | |
c( "FAM" = "E", "HEX" = "IC", "Cal Red 610" = "R", "Quasar 670" = "N" ) ->flph2gene | |
tbl %>% | |
left_join( testres %>% select( Sample=labId, reportedRes ) %>% distinct ) %>% | |
mutate_at( "reportedRes", replace_na, "NA" ) %>% | |
mutate( sampleType = ifelse( str_starts( Sample, fixed("V20") ), | |
str_c( "sample/", reportedRes ), | |
Sample ) ) %>% | |
mutate( sampleType = ifelse( sampleType %in% as.character( 1:42 ), "numbered", sampleType ) ) %>% | |
mutate_at( "sampleType", factor ) %>% | |
mutate_at( "sampleType", fct_relevel, "NC", "PC", "sample/negative", "sample/positive", | |
"sample/inconclusive", "sample/NA", "numbered" ) -> tbl2 | |
pdf( width=12, height=7 ) | |
tbl2 %>% pull(plateId) %>% unique() %>% walk( function(plt) { | |
(tbl2 %>% | |
filter( plateId == plt ) %>% | |
mutate( facet = sprintf( "%s (%s)", gene, flph ) ) %>% | |
arrange( sampleType != "sample/negative" ) %>% | |
mutate_at( "Well", fct_inorder ) %>% | |
ggplot + | |
geom_line( aes( x=Cycle, y=value, group=Well, col=sampleType ), alpha=.6 ) + | |
facet_wrap( ~ facet, scales = "free_y" ) + | |
ggtitle( plt ) + | |
scale_color_manual( drop=FALSE, values = c( "darkblue", "red", "lightblue", "orange", | |
"brown", "gray", "darkgray" ) ) ) %>% print | |
} ) | |
dev.off() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With thick lines for samples that are positive according to TibMolBio E-gene, but negative for Seegene's E-gene
https://drive.google.com/file/d/1K5s7J_tUI1imGSX1MkFFv2xraZwysQLH/view?usp=sharing
(pdf)