Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • IsBeth
    Member
    • Nov 2013
    • 28

    Looking for replicated conditions

    Hello! I'm a newbie and I'm trying to write a function which can read how much replicated conditions there are in an experimental design in a given case. For example, if I have a design (for example an input like a data.frame) like the following:

    sample condition
    1 C1.sam A
    2 C2.sam A
    3 C2.sam A
    4 Infect1.sam B
    5 Infect2.sam B
    6 Infect3.sam B

    How can I access the number of replicates? (perhaps some function similar to apply?) Cause obviously there are three replicates called "A" and three replicates called "B", but I don´t know how to store this in a variable, so I can work with that information later on the script.

    Thanks and sorry for my beginner's English
  • dpryan
    Devon Ryan
    • Jul 2011
    • 3478

    #2
    It sort of depends on how you want to use things later on. If the dataframe is called "d", then:

    Code:
    table(d)
    That will give you a table with the conditions as names and counts as values. In general, though, you can just "~d$condition" or use model.matrix.

    Comment

    • IsBeth
      Member
      • Nov 2013
      • 28

      #3
      Thank u dpryan. The table-function worked =)

      What if I wanted to use a function like that with my counts, not with my design table? A data frame like this for example:

      Control1 Control2 Control3 Infect1 Infect2 Infect3
      4 34 23 12 2 33
      6 14 15 17 32 22

      I want to get the information that the condition "control" is replicated 3 times, and condition "infect" is replicated 3 times, too (so that R get just the information in common ignoring the numbers).

      Comment

      • dpryan
        Devon Ryan
        • Jul 2011
        • 3478

        #4
        There's no simple function for that since R would have to already know your general labeling format. Presuming that numbers at the end of sample names can always be stripped, then the general idea would be to:

        1) Save the names in another variable (foo <- names(d))
        2) Remove numbers from the end (normally this would be a regex)
        3) You could then use things like "table" or whatever on the results.

        Of course, if you new ahead of time what the groups were you could just count how many contain a phrase (i.e., use grep), but I'm assuming you want to do this as part of a general purpose pipeline.

        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, 07-02-2026, 11:08 AM
        0 responses
        11 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 06-30-2026, 05:37 AM
        0 responses
        14 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 06-26-2026, 11:10 AM
        0 responses
        20 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 06-17-2026, 06:09 AM
        0 responses
        54 views
        0 reactions
        Last Post SEQadmin2  
        Working...