Hi I am new to R.
I have multiple files and I want to command these files separately. (I have about 200 files)
Using for loop or lapply, how can I command these for each file automatically? I want to tag sample names in Barcode and filenames like sample1, sample2, sample3...
sample1 <- read.delim("sample1.hg38_multianno.txt", header = F)
colnames(sample1)[1:10] = c("Chr", "Start", "End", "Ref", "Alt", "Func.refGene", "Gene.refGene", "GeneDetail.refGene", "ExonicFunc.refGene","AAChange.refGene")
sample1 <- sample1[30:nrow(sample1),]
sample1 <- sample1[,-c(11:87)]
sample1$Tumor_Sample_Barcode = "sample1"
write.table(sample1, file="sample1.txt", row.names = FALSE, sep = "\t", quote = FALSE)
sample1.maf = maftools::annovarToMaf(annovar = "sample1.txt",
Center = NULL,
refBuild = 'hg38',
tsbCol = 'Tumor_Sample_Barcode',
table = 'refGene')
write.table(sample1.maf, file="sample1.maf", row.names = FALSE, sep = "\t", quote = FALSE)
Thank you in advance