R/scores2list.R

Defines functions scores2list

# score data frame must have an attribut called map containing the mapping to chromosomes
scores2list <- function(scores){
  map = attr(scores, "map")
  primer = NULL
  bp = NULL
  x = tidyr::gather(scores,key = primer, value = bp, 2:ncol(scores))
  x = x[!is.na(x$bp), ]
  x = x[x$bp != 0, ]
  x = as.data.frame(x, stringsAsFactors = FALSE)
  x[, 1] = as.character(x[, 1])
 
  m = marker2primer(x$primer)
  
  x = as.data.frame(cbind(x$accession_id, m), stringsAsFactors = FALSE)
  x[, 3] = as.integer(x[, 3])
  names(x) = c("accession_id", "primer", "marker_size")
  y=dplyr::full_join(x, map, by="primer")
  names(y) = c("accession_id", "primer_name", "marker_size", "map_location")
  y
}
c5sire/quipu documentation built on Nov. 14, 2020, 9:09 a.m.