Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #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

    • seqadmin
      Latest Developments in Precision Medicine
      by seqadmin



      Technological advances have led to drastic improvements in the field of precision medicine, enabling more personalized approaches to treatment. This article explores four leading groups that are overcoming many of the challenges of genomic profiling and precision medicine through their innovative platforms and technologies.

      Somatic Genomics
      “We have such a tremendous amount of genetic diversity that exists within each of us, and not just between us as individuals,”...
      05-24-2024, 01:16 PM
    • seqadmin
      Recent Advances in Sequencing Analysis Tools
      by seqadmin


      The sequencing world is rapidly changing due to declining costs, enhanced accuracies, and the advent of newer, cutting-edge instruments. Equally important to these developments are improvements in sequencing analysis, a process that converts vast amounts of raw data into a comprehensible and meaningful form. This complex task requires expertise and the right analysis tools. In this article, we highlight the progress and innovation in sequencing analysis by reviewing several of the...
      05-06-2024, 07:48 AM

    ad_right_rmr

    Collapse

    News

    Collapse

    Topics Statistics Last Post
    Started by seqadmin, 06-03-2024, 06:55 AM
    0 responses
    12 views
    0 likes
    Last Post seqadmin  
    Started by seqadmin, 05-30-2024, 03:16 PM
    0 responses
    26 views
    0 likes
    Last Post seqadmin  
    Started by seqadmin, 05-29-2024, 01:32 PM
    0 responses
    29 views
    0 likes
    Last Post seqadmin  
    Started by seqadmin, 05-24-2024, 07:15 AM
    0 responses
    215 views
    0 likes
    Last Post seqadmin  
    Working...
    X