This is probably a really quick/simple fix but I am a Noob to R programming/programming in general. I am trying to create a for loop that runs the test multiple times with different FDR values (5,10,20). How do I make it run 3 times with different values and then produce 3 different datasets with names like... atac.glmtop.males.opening.fdr5
, atac.glmtop.males.opening.fdr10
, atac.glmtop.males.opening.fdr20
? Also is there a way to make the write.table
function work so that it exports files with the fdr5, fdr10, fdr20 in the name?
fdr.nums = c("5","10","20")
fdr.nums.vector = c(5,10,20)
for (i in 1:length(fdr.list)){
atac.glmtop.males.opening.fdr[i] <- topTags(
atac.glmfit.males,
n = nrow(atac.dge$counts),
sort.by = "none",
adjust.method = "fdr"
)$table %>%
tibble::rownames_to_column("peakco") %>%
filter(logFC < 0) %>%
filter(FDR < (fdr.vector[i]/100)) %>%
merge(.,annotated.atac.pbmc.narrow, by="peakco" ) %>%
tibble::column_to_rownames("peakco")
atac.glmtop.males.opening.fdr[i]
write.table(
atac.glmtop.males.fdr[i].opening[,c("chr", "start","end")],
file = paste0("~/Downloads/sexM.age.groupHO.fdr",i, ".opening.bed"),
sep = "\t",
quote = FALSE,
row.names = FALSE,
col.names = FALSE
)
write.table(
atac.glmtop.males.fdr[i].opening["GeneName"],
file = "~/Downloads/sexM.age.groupHO.fdr"+ i + ".opening.GeneNames.txt",
sep = "\t",
quote = FALSE,
row.names = FALSE,
col.names = FALSE
)
}