how to deal with multiple barcodes/index in the analysis
2
0
Entering edit mode
XIA.PAN ▴ 20
@xiapan-12407
Last seen 5.1 years ago

Dear all,

I have a set of NGS data, that barcoded from B1 to B12, each one of the codes represents one sample.

I need to apply analysis/calculation on these samples and I often find myself writing multiple lines, for example, convert multiple tables to multiple data.frames using the following:

B1.frame = as.data.frame(B1)

B2.frame = as.data.frame(B2)

.........

B12.frame = as.data.frame(B12)

I tried to use for loop to simply the codes, but it didn't work. Is there a way to use a loop so that I don't need to write 12 lines all the time while processing files with 'B1-B12' in the filename.

This is not quite Bioconductor related and I couldn't work it out simply because I am a newbie. It would be great if someone can help, especially I need to use 96 barcodes in the future.

Thank you!

dnastringset aastringset • 1.0k views
ADD COMMENT
0
Entering edit mode
@james-w-macdonald-5106
Last seen 1 hour ago
United States

You are right. This isn't really a Bioconductor question, and should probably be asked on R-help (r-help@r-project.org).

In addition, it isn't really clear what you are trying to do. But if I assume you have, like, 12 things called B1-B12 that are matrices or something and you want to make them all data.frames with new names (why?), then you could use a combination of assign and get.

for(i in 1:12) assign(paste0("B", i, ".frame")), as.data.frame(get(paste("B", i))))

 

ADD COMMENT
0
Entering edit mode
XIA.PAN ▴ 20
@xiapan-12407
Last seen 5.1 years ago

Hi James,

I am trying to compare the DNA sequences and their frequencies in Table B1-B12. I would like to cbind all 12 tables to a data.frame and normalize each freq to the total seqs number.  But the number of DNA sequences and their frequencies in each Bi file are different. cbind ignores the NAs, causing less total DNA seqs. cbind.na needs a colname, which I cannot assign to a table. So I converted all tables to df then Reduce, merge dfs to get the final df. 

Thank you for your help.

XIA

  

ADD COMMENT

Login before adding your answer.

Traffic: 693 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6