Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • tonybert
    Member
    • Aug 2012
    • 38

    sample gene count matrix from list in R

    Greetings, I am trying to produce a sample matrix consisting of samples (columns) and gene-IDs (rows), with the raw hits for each gene in the matrix. For COG categories, I have been able to produce these types of tables quite easily in excel. However, for other types of gene-ontology databases that are a bit more complex, i have been running into some problems. What i have currently is a list that looks like the below:

    >count_pFAM_samplelist
    count pFAM sample
    1 2 1A1D_ACIAC/10-323 1
    2 3 1A1D_AGRRK/9-322 1
    3 1 1A1D_BURCC/10-323 1
    4 1 1A1D_CUPNH/9-323 1
    5 1 1A1D_METNO/9-322 1
    6 2 1A1D_METPP/10-323 1
    7 3 1A1D_METS4/9-322 1
    8 1 1A1D_PSES0/11-323 1
    9 1 1A1D_PSEUD/10-323 1
    10 2 1A1D_RHIRD/10-322 1
    11 2 14312_ARATH/10-245 2
    12 1 1433_EIMTE/9-256 2
    13 1 1433_SPIOL/1-198 2
    14 1 1A1D_ACIAC/10-323 2
    15 4 1A1D_AGRRK/9-322 2
    16 1 1A1D_CUPNH/9-323 2
    17 2 1A1D_METNO/9-322 2
    18 6 1A1D_METPP/10-323 2
    19 1 1A1D_METS4/9-322 2
    20 2 1A1D_PSEUD/10-323 2

    what I would like to do is transform this into a matrix with "sample" in columns, pFAM in rows, with count listed in the matrix. If anyone has any suggestions, they would be helpful. Thanks,

    -Tony
  • dpryan
    Devon Ryan
    • Jul 2011
    • 3478

    #2
    Do each of the samples at least have a row for each of the pFAM IDs (assuming the example is sorted, it would seem not)? That would make life easier (and make things more amenable to conversion in R). If not, presumably you would want a 0 used when an entry is missing entirely. The general idea would be to split() that by "sample", lapply() a function to simple return the counts, and then convert that list into a matrix. But that'll only work for well behaved data (otherwise, just script something in python or whatever other language you know, since iteration is really slow in R).

    Comment

    Latest Articles

    Collapse

    • GATTACAT
      Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
      by GATTACAT
      Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
      07-01-2026, 11:43 AM
    • SEQadmin2
      Nine Things a Sample Prep Scientist Thinks About Before Sequencing
      by SEQadmin2


      I’m not a sequencing expert. I’m a purification scientist who uses NGS to evaluate workflows my group develops. With this perspective, we think about the sample first and the NGS workflow second. The sequencer is an exceptionally honest reporter, but it can only report on what you give it, so whether you get clean, interpretable data from an NGS workflow is largely determined before you begin.

      Here are nine questions we think about, in roughly the order they matter, before...
      06-18-2026, 07:11 AM

    ad_right_rmr

    Collapse

    News

    Collapse

    Topics Statistics Last Post
    Started by SEQadmin2, Today, 11:05 AM
    0 responses
    6 views
    0 reactions
    Last Post SEQadmin2  
    Started by SEQadmin2, 07-02-2026, 11:08 AM
    0 responses
    28 views
    0 reactions
    Last Post SEQadmin2  
    Started by SEQadmin2, 06-30-2026, 05:37 AM
    0 responses
    25 views
    0 reactions
    Last Post SEQadmin2  
    Started by SEQadmin2, 06-26-2026, 11:10 AM
    0 responses
    25 views
    0 reactions
    Last Post SEQadmin2  
    Working...