|
1 | | -#!/usr/bin/env Rscript |
2 | | - |
3 | | -# set working directory |
4 | 1 | setwd("QC_out/") |
5 | | - |
6 | | -# save working directory as pathSTD |
7 | 2 | pathSTD<-getwd() |
| 3 | +library(stringr) |
| 4 | + |
| 5 | + |
8 | 6 |
|
9 | | -# list mono-nucleosome and sub-nucleosome BAM files |
10 | 7 | files.mono<-list.files("RUN/00_ALIGNMENT/monoNuc/") |
11 | 8 | files.sub<-list.files("RUN/00_ALIGNMENT/subNuc/") |
12 | 9 |
|
13 | | -# Change sample name by splitting at "_MNase_" and taking the first part |
14 | | -Sample_Name <- sapply(strsplit(files.mono, "_MNase_"), `[`, 1) |
| 10 | +##sample name |
| 11 | +Sample_Name<-files.mono %>% |
| 12 | + str_split_i("_MNase_",1) |
| 13 | + |
| 14 | +replicate<-files.mono %>% |
| 15 | + str_split_i("_",5) |
| 16 | + |
15 | 17 |
|
16 | | -# Extract replicate number by splitting at "_" and taking the sixth element |
17 | | -replicate <- sapply(strsplit(files.mono, "_"), `[`, 6) |
| 18 | +MNase_U<-files.mono %>% |
| 19 | + str_split_i("_",3) %>% |
| 20 | + str_sub(1,-2) |
18 | 21 |
|
19 | | -# Extract MNase units by splitting at "_" and taking the fourth element, then removing the last character |
20 | | -MNase_U <- sapply(strsplit(files.mono, "_"), function(x) substr(x[4], 1, nchar(x[4])-1)) |
21 | 22 |
|
22 | | -# create data frame with sample name and corresponding file names for mono- and sub- nucleosomes |
23 | 23 | df<-data.frame(Sample_Name=Sample_Name, |
24 | 24 | replicate=replicate, |
25 | | - path_mono=paste0(pathSTD,"/RUN/00_ALIGNMENT/monoNuc/",files.mono), |
26 | | - path_sub=paste0(pathSTD,"/RUN/00_ALIGNMENT/subNuc/",files.sub), |
27 | | - MNase_U) |
| 25 | + path_mono=paste0(pathSTD,"/RUN/00_ALIGNMENT/monoNuc/",files.mono), |
| 26 | + path_sub=paste0(pathSTD,"/RUN/00_ALIGNMENT/subNuc/",files.sub), |
| 27 | + MNase_U) |
28 | 28 |
|
29 | | -# write .csv file with sample names and paths |
30 | 29 | write.csv(df, row.names = F, |
31 | | - file = paste0(pathSTD,"/data/samples_nucMACC.csv", quote = F) |
| 30 | + file="../data/samples_nucMACC.csv", quote = F) |
0 commit comments