Guest User

Untitled

a guest
Jun 18th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. # arguments
  2. fp <- "RNA 2018_06_17 4_37_03.tsv" # ファイルパス
  3. smp <- c("young_leaf_1", "young_leaf_2", "matured_leaf_1", "matured_leaf_2") # サンプル名
  4.  
  5. # parse tsv
  6. ndrop <- readLines(fp)
  7. st <- grep("サンプル", ndrop)
  8. ed <- c((st-1)[-1], length(ndrop))
  9. res <- mapply(function(x,y){ndrop[x:y]}, st, ed)
  10.  
  11. lst_al <- lapply(seq_along(res), function(i){
  12. x <- res[[i]]
  13. x[nchar(x)!=0] %>%
  14. .[-1:-grep("//QSpecEnd:", .)] %>%
  15. strsplit(., "\t") %>% data.frame(.) %>%
  16. t() %>%
  17. data.frame(., row.names=NULL, stringsAsFactors=F) %>%
  18. setNames(., c("wave_length", smp[i]))
  19. })
  20.  
  21. dat <- Reduce(function(x,y){merge(x,y, by="wave_length")}, lst_al) %>%
  22. tidyr::gather(., key="sample", value="absorbance", -1) %>%
  23. mutate_at(vars(c(1,3)), funs(as.numeric))
  24.  
  25. # plot
  26. ggplot(dat, aes(x=wave_length, y=absorbance, colour=sample)) + geom_line()
Add Comment
Please, Sign In to add comment