SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
Human whole blood RNA seq benchmarks? HISAT-stringtie-ballgown liumangmang RNA Sequencing 0 01-03-2017 04:23 AM
Troubles installing ballgown batel RNA Sequencing 2 03-26-2015 05:51 AM
Flexible isoform-level differential expression analysis with Ballgown Ben Langmead Bioinformatics 0 03-30-2014 10:39 AM
allele information from samtools mpileup contents fatakias Bioinformatics 2 11-07-2012 08:49 AM
Rapid Library Kit contents lhandley 454 Pyrosequencing 2 05-03-2010 11:34 AM

Reply
 
Thread Tools
Old 02-21-2017, 01:44 AM   #1
rwan
Member
 
Location: Hong Kong

Join Date: Feb 2013
Posts: 11
Default Contents of ballgown object

Dear all,

I'm new to ballgown and one of the things I'd like to do is to create a PCA plot using R / ggplot2's ggfortify. I have something like this so far:

Code:
pheno_data <- read.csv ("phenodata.csv")

bg = ballgown (...)
bg_filter = subset (bg, "rowVars (gexpr (bg)) > 1", genomesubset=TRUE)
y <- log2 (gexpr (bg_filter) + 1)
pca <- prcomp (t (y))

autoplot (pca)
and this works nicely, but I'd like to colour the points by sample. For example, see https://cran.r-project.org/web/packa.../plot_pca.html

As the above web page describes, I can colour it by giving it a "colour = 'Species'" argument...this is a vector which lists the sample names (as a factor).

Does anyone know what I'm missing? I *think* I'm close...but I'm not sure what I need to do.

Thank you!

Ray
rwan is offline   Reply With Quote
Old 01-26-2019, 04:39 PM   #2
philipp.bayer
Junior Member
 
Location: Australia

Join Date: May 2014
Posts: 2
Default

I know this is kind of old, but here's how I solved it (since there's not much else on Google for this solution??)

Let's say you have a ballgown object by the name of bg, and a table with your conditions named pheno_data:

Code:
bg = ballgown(samples=as.vector(sample_full_path),pData=pheno_data)

# run the PCA
y = log2(texpr(bg)+1)
pca = prcomp(t(y))
pcmat = pca$x
# make a new data frame with the data we want
pcmat = data.frame(Name=str_replace(rownames(pcmat), 'FPKM.', ''), PC1=pcmat[,1], PC2=pcmat[,2], group=pheno_data$condition)

library(ggrepel)
library(ggplot2)
# plot the PCA with nice labels
ggplot(data=pcmat, aes(x=PC1, y=PC2, colour=group, label=Name)) + geom_point() + geom_label()
# save the thing
ggsave('PCA.png', height=15, width=15, unit='cm')
Then you get a nice PCA plot with labels based on each name (here the individuals' names) colored by their group.
philipp.bayer is offline   Reply With Quote
Reply

Tags
ballgown, ggfortify, ggplot2

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -8. The time now is 08:01 PM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO