Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # arguments
- fp <- "RNA 2018_06_17 4_37_03.tsv" # ファイルパス
- smp <- c("young_leaf_1", "young_leaf_2", "matured_leaf_1", "matured_leaf_2") # サンプル名
- # parse tsv
- ndrop <- readLines(fp)
- st <- grep("サンプル", ndrop)
- ed <- c((st-1)[-1], length(ndrop))
- res <- mapply(function(x,y){ndrop[x:y]}, st, ed)
- lst_al <- lapply(seq_along(res), function(i){
- x <- res[[i]]
- x[nchar(x)!=0] %>%
- .[-1:-grep("//QSpecEnd:", .)] %>%
- strsplit(., "\t") %>% data.frame(.) %>%
- t() %>%
- data.frame(., row.names=NULL, stringsAsFactors=F) %>%
- setNames(., c("wave_length", smp[i]))
- })
- dat <- Reduce(function(x,y){merge(x,y, by="wave_length")}, lst_al) %>%
- tidyr::gather(., key="sample", value="absorbance", -1) %>%
- mutate_at(vars(c(1,3)), funs(as.numeric))
- # plot
- ggplot(dat, aes(x=wave_length, y=absorbance, colour=sample)) + geom_line()
Add Comment
Please, Sign In to add comment