Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rozitaa
    Member
    • Jun 2013
    • 51

    #1

    How to cluster samples with PCA in R?

    Hi,

    I have RNA-seq data for 16 mouse samples. I would like to cluster cufflinks results of these samples by PCA in R. The data looks like this:


    PHP Code:
    gene_id    gene_short_name    FPKM_101    FPKM_102    FPKM_103    FPKM_104    FPKM_105    FPKM_106    FPKM_107    FPKM_108    FPKM_109    FPKM_110    FPKM_111    FPKM_112    FPKM_113    FPKM_114    FPKM_115    FPKM_116
    uc007aeu.1    
    -    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
    uc007aev.1    
    -    0    0    0.0095358    0.0095358    0.011704    1.48E-10    2.05E-63    0.0083273    0.014457    0.0068505    0.0053635    0.022235    0.0047757    0.018794    0    0.01661
    uc007aew.1    
    -    0    0    0    0    0    1.2568    0.27389    0    0    0    0    0    0    0    0    0
    uc007aex.2    
    -    0    0    0    0    0    7.1538    0.0096687    0    0    0    0    0    0    0    0.0050925    0
    uc007aey.1    
    -    8.27E-07    0.00049201    0.00043141    0.00043141    0.00079353    0    0.00074324    1.56E-09    3.39E-20    1.16E-61    1.80E-20    1.72E-09    1.56E-96    5.13E-07    5.34E-07    4.78E-07
    uc007afb.1    
    -    0.40549    2.08E-248    1.11E-19    1.11E-19    2.40E-93    0    0.49777    0.10711    1.22E-12    0.014644    6.48E-13    0.11777    0.02695    0.25169    0.08951    0.080144
    uc007afc.1    
    -    1.93E-06    0.38845    0.34061    0.34061    0.31315    0    0    5.01E-09    1.04E-19    0.00046243    5.53E-20    5.51E-09    0.17202    1.20E-06    1.16E-06    1.04E-06 
    Commands in R:
    PHP Code:
    data=read.csv('raw_cuff_data.csv', header=TRUE)
    data_pca <- prcomp(data[, 3:18]) 
    How should I plot them in order to see clustered samples. I know my pca data are in data_pca$x, but how should I cluster them? and plot one point for each sample?

    Thanks
  • dariober
    Senior Member
    • May 2010
    • 311

    #2
    Originally posted by rozitaa View Post
    Hi,

    I have RNA-seq data for 16 mouse samples. I would like to cluster cufflinks results of these samples by PCA in R. The data looks like this:

    How should I plot them in order to see clustered samples. I know my pca data are in data_pca$x, but how should I cluster them? and plot one point for each sample?

    Thanks
    Hi - Try something along these lines...

    Code:
    ## Test data:
    dat<- matrix(data= rnorm(n= 10000), ncol= 10)
    colnames(dat)<- paste('sample_', 1:ncol(dat), sep= '')
    
    ## PCA
    pcaResult<-prcomp(t(dat))
    
    ## Set up plot
    plot(pcaResult$x,
        main= 'Principal components of samples',
        xlab= sprintf('PC1 (sd: %s%%)', round(100 * (pcaResult$sdev[1] / sum(pcaResult$sdev)))),
        ylab= sprintf('PC2 (sd: %s%%)', round(100 * (pcaResult$sdev[2] / sum(pcaResult$sdev)))),
        type= 'n'
    )
    
    ## Plot labels
    text(x= pcaResult$x[,1], y= pcaResult$x[,2], labels= rownames(pcaResult$x), cex= 0.5)
    Samples similar to each other will group together in the plot but keep in mind that PCA doesn't do any clustering.

    Dario

    Comment

    • rozitaa
      Member
      • Jun 2013
      • 51

      #3
      Thanks, a lot. I also transposed my data and I got the exact pca plot that I wanted. I just wasn't sure if that's the correct way.

      Comment

      • Jeremy
        Senior Member
        • Nov 2009
        • 190

        #4
        There is a nice PCA generated in the DESeq2 vignette that you could look at and apply to your cufflinks data.

        Comment

        Latest Articles

        Collapse

        • SEQadmin2
          16S/ITS Profiling vs. Shotgun Metagenomics: What Changes in Your Workflow?
          by SEQadmin2




          NGS has revolutionized clinical microbiology by offering new ways to identify and surveil pathogens without prior knowledge of the target. One popular approach is 16S rRNA and ITS amplicon sequencing, which targets specific microbial markers. But studies are increasingly incorporating shotgun metagenomics, a technique that sequences all DNA from a sample without targeting specific microbial markers. This approach allows more detailed taxonomic classification, detection...
          Yesterday, 06:46 AM
        • SEQadmin2
          Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
          by SEQadmin2



          Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

          Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
          ...
          10-14-2026, 09:55 AM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by SEQadmin2, 10-28-2026, 09:57 AM
        0 responses
        29 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-28-2026, 09:51 AM
        0 responses
        20 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-22-2026, 11:13 AM
        0 responses
        71 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-22-2026, 10:48 AM
        0 responses
        48 views
        0 reactions
        Last Post SEQadmin2  
        Working...