here is the ammended script for anyone who is interested. make sure you have your data in a sub directory called “Data” and edit ~/Desktop/MACE_DEMUX_FASTQs/barcode11 to be your parent directory
#!/usr/bin/env Rscript
library(tidyverse)
data_path <- paste("~/Desktop/MACE_DEMUX_FASTQs/barcode11", “Data”, sep = “/”)
SamplesF <- list.files(path = data_path, pattern = “*.R1.fastq.gz”, all.files = FALSE,
full.names = TRUE, recursive = FALSE,
ignore.case = FALSE, include.dirs = FALSE, no… = FALSE)
TabF <- as.data.frame(SamplesF)
PathF <- data.frame(lapply(TabF, function(TabF) {gsub(“Data/”, “$PWD/N/”, TabF)}))
PathF <- data.frame(lapply(PathF, function(PathF) {gsub(“fastq.gz”, “fastq.gip”, PathF)}))
names(PathF)[names(PathF)==“SamplesF”] <- “absolute-filepath”
PathF[‘direction’]=‘forward’
PathF[‘sample-id’]= SamplesF
PathF <- data.frame(lapply(PathF, function(PathF) {gsub(“Data/”, “sample-”, PathF)}))
PathF <- data.frame(lapply(PathF, function(PathF) {gsub(".R1.fastq.gz", “”, PathF)}))
PathF <- data.frame(lapply(PathF, function(PathF) {gsub(“fastq.gip”, “fastq.gz”, PathF)}))
PathF <- data.frame(lapply(PathF, function(PathF) {gsub("/N/", “/Data/”, PathF)}))
PathF <- PathF[,c(3,1,2)]
SamplesR <- list.files(path = data_path, pattern = “*.R2.fastq.gz”, all.files = FALSE,
full.names = TRUE, recursive = FALSE,
ignore.case = FALSE, include.dirs = FALSE, no… = FALSE)
TabR <- as.data.frame(SamplesR)
PathR <- data.frame(lapply(TabR, function(TabR) {gsub(“Data/”, “$PWD/N/”, TabR)}))
PathR <- data.frame(lapply(PathR, function(PathR) {gsub(“fastq.gz”, “fastq.gip”, PathR)}))
names(PathR)[names(PathR)==“SamplesR”] <- “absolute-filepath”
PathR[‘direction’]=‘reverse’
PathR[‘sample-id’]= SamplesR
PathR <- data.frame(lapply(PathR, function(PathR) {gsub(“Data/”, “sample-”, PathR)}))
PathR <- data.frame(lapply(PathR, function(PathR) {gsub(".R2.fastq.gz", “”, PathR)}))
PathR <- data.frame(lapply(PathR, function(PathR) {gsub(“fastq.gip”, “fastq.gz”, PathR)}))
PathR <- data.frame(lapply(PathR, function(PathR) {gsub("/N/", “/Data/”, PathR)}))
PathR <- PathR[,c(3,1,2)]
Manifest <- rbind(PathF, PathR)
names(Manifest)[names(Manifest)==“sample.id”] <- “sample-id”
names(Manifest)[names(Manifest)==“absolute.filepath”] <- “absolute-filepath”
write_csv(Manifest, “Manifest.csv”)