Skip to content

Commit 2e00728

Browse files
committed
The "SNP output" table now contains the actual SNP position reported in the vcf instead of SNP.id; previous version of fish1_posinfo.rds and fish2_posinfo.rds have mismatching content - replaced with randomly generated pos
1 parent d38c4ce commit 2e00728

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed
-535 Bytes
Binary file not shown.
-349 Bytes
Binary file not shown.

inst/shiny/microhaplot/server.R

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ while the bottom panel hosts a wide selection of tables and graphical summaries.
104104

105105
pos.file <- strsplit(input$selectDB, split=".rds") %>% unlist %>% paste0(.,"_posinfo.rds")
106106
if (!file.exists(pos.file)) return ()
107-
readRDS(pos.file)
108-
107+
readRDS(pos.file) %>% dplyr::as_tibble(stringsAsFactors=F)
109108
})
110109

111110
# the format structure for the annotate file: contains locus ID (also contains ALL), min read depth, min allelic ratio,
@@ -2967,7 +2966,7 @@ while the bottom panel hosts a wide selection of tables and graphical summaries.
29672966
pos.file <- extract.pos.file()
29682967
if(is.null(pos.file)) return()
29692968
colnames(pos.file) <- c("locus", "pos")
2970-
pos.str <- pos.file %>% filter(locus==input$selectLocus) %>% select(pos) %>% unlist
2969+
pos.str <- pos.file %>% filter(locus==input$selectLocus) %>% select(pos) %>% unlist %>% as.character()
29712970
position <- strsplit(pos.str, ",") %>% unlist %>% as.numeric
29722971

29732972
if (is.null(haplo.filter) || nrow(haplo.filter) == 0) return()
@@ -3470,7 +3469,22 @@ while the bottom panel hosts a wide selection of tables and graphical summaries.
34703469
}
34713470

34723471
if (isolate(input$selectTbl) == "SNP report") {
3472+
if (is.null(haplo.summaryTbl())) return()
34733473
haplo.summaryTable <- haplo.summaryTbl()
3474+
3475+
pos.file <- extract.pos.file()
3476+
if(is.null(pos.file)) return()
3477+
colnames(pos.file) <- c("locus", "pos")
3478+
pos.file$pos <- as.character(pos.file$pos)
3479+
3480+
pos.str <- pos.file %>% group_by(locus) %>%
3481+
mutate(pos = strsplit(pos, ",")) %>%
3482+
unnest(pos) %>%
3483+
mutate(pos = as.numeric(pos)) %>%
3484+
arrange(pos) %>%
3485+
group_by(locus) %>%
3486+
mutate(snp.id = row_number())
3487+
34743488
n.base <- nchar(haplo.summaryTable$haplotype.1)
34753489
haplo.all <-
34763490
haplo.summaryTable[rep(seq(1, nrow(haplo.summaryTable)), n.base),] %>%
@@ -3484,7 +3498,10 @@ while the bottom panel hosts a wide selection of tables and graphical summaries.
34843498
select(-haplotype.1,-haplotype.2,-read.depth.1,-read.depth.2) %>%
34853499
rename("indiv.ID" = id)
34863500

3487-
write.csv(haplo.all, file)
3501+
haplo.all <- left_join(haplo.all, pos.str, by=c("locus", "snp.id")) %>%
3502+
select(group, locus, indiv.ID, pos, snp, ar)
3503+
3504+
write.csv(haplo.all, file, row.names=FALSE)
34883505

34893506
}
34903507
if (isolate(input$selectTbl) == "locus annotation") {
@@ -3555,9 +3572,21 @@ while the bottom panel hosts a wide selection of tables and graphical summaries.
35553572

35563573
if (input$selectTbl == "SNP report") {
35573574
if (is.null(haplo.summaryTbl())) return()
3575+
haplo.summaryTable <- haplo.summaryTbl()
35583576

3577+
pos.file <- extract.pos.file()
3578+
if(is.null(pos.file)) return()
3579+
colnames(pos.file) <- c("locus", "pos")
3580+
pos.file$pos <- as.character(pos.file$pos)
3581+
3582+
pos.str <- pos.file %>% group_by(locus) %>%
3583+
mutate(pos = strsplit(pos, ",")) %>%
3584+
unnest(pos) %>%
3585+
mutate(pos = as.numeric(pos)) %>%
3586+
arrange(pos) %>%
3587+
group_by(locus) %>%
3588+
mutate(snp.id = row_number())
35593589

3560-
haplo.summaryTable <- haplo.summaryTbl()
35613590
n.base <- nchar(haplo.summaryTable$haplotype.1)
35623591
haplo.all <-
35633592
haplo.summaryTable[rep(seq(1, nrow(haplo.summaryTable)), n.base),] %>%
@@ -3570,6 +3599,9 @@ while the bottom panel hosts a wide selection of tables and graphical summaries.
35703599
)) %>%
35713600
select(-haplotype.1,-haplotype.2,-read.depth.1,-read.depth.2) %>%
35723601
rename("indiv.ID" = id)
3602+
3603+
haplo.all <- left_join(haplo.all, pos.str, by=c("locus", "snp.id")) %>%
3604+
select(group, locus, indiv.ID, pos, snp, ar)
35733605
}
35743606

35753607
if (isolate(input$selectTbl) == "locus annotation") {

0 commit comments

Comments
 (0)