0

I have multiple bed-files which are basically 3 coordinate files. So right now Im doing as such

Read the files and turn them into GRange objects. I have different sets which are in same folder for Blast_NPM1

B19 <- read.table("HSC_CMP_GMP_MONO_ATAC/HSC_CMP_ATAC_bed/Blast_mutation/Blast_NPM1/Blast19.bed",header = FALSE)
B20 <- read.table("HSC_CMP_GMP_MONO_ATAC/HSC_CMP_ATAC_bed/Blast_mutation/Blast_NPM1/Blast20.bed",header = FALSE)
B21 <- read.table("HSC_CMP_GMP_MONO_ATAC/HSC_CMP_ATAC_bed/Blast_mutation/Blast_NPM1/Blast21.bed",header = FALSE)
B9 <- read.table("HSC_CMP_GMP_MONO_ATAC/HSC_CMP_ATAC_bed/Blast_mutation/Blast_NPM1/Blast9.bed",header = FALSE)

B19 <- GRanges(
  B19$V1,IRanges(B19$V2,B19$V3),
  strand="*"
  )

B20 <- GRanges(
  B20$V1,IRanges(B20$V2,B20$V3),
  strand="*"
)

B21 <- GRanges( B21$V1,IRanges(B21$V2,B21$V3),strand="*" )

B9 <- GRanges( B9$V1,IRanges(B9$V2,B9$V3),strand="*" )

I have removed the plotting part it can be done later This i have to kind of repeat for different sets ..

How do I turn this into a function ? Any suggestion or help would be really appreciated.

PesKchan
  • 868
  • 6
  • 14
  • 1
    Do you want to perform this for multiple sets of 4 files? – Ronak Shah May 10 '21 at 06:27
  • yes as an example I have 4 files ..so i have like different folders for different mutation – PesKchan May 10 '21 at 07:49
  • Sorry, it is not clear to me. Can you explain how will you do this for two iterations manually? – Ronak Shah May 11 '21 at 03:42
  • So I have like these coordinates file for class of mutation I have to see what the number of peaks present there ,first step is I have to read the files and then using those objects I have to covert them into Granges , i dont need to plot I simply want to count the number of rows like this df <-rbind length(B1), length(B16) , length(B2) , length(B3),length(B4), length(B5) ,length(B6)) to get number of peak in each condition .. – PesKchan May 11 '21 at 04:08
  • 1
    Hmm...I still don't get it. Maybe an example would make it clear. Nonetheless, https://www.biostars.org/p/386585/ or https://stackoverflow.com/questions/45558642/finding-all-overlaps-in-one-iteration-of-foverlap-in-rs-data-table/45574386#45574386 might be helpful. – Ronak Shah May 11 '21 at 04:30
  • Thank you for the link i think that will get my work done – PesKchan May 11 '21 at 04:53

0 Answers0