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 05:23 AM
Troubles installing ballgown batel RNA Sequencing 2 03-26-2015 06:51 AM
Flexible isoform-level differential expression analysis with Ballgown Ben Langmead Bioinformatics 0 03-30-2014 11:39 AM
allele information from samtools mpileup contents fatakias Bioinformatics 2 11-07-2012 09:49 AM
Rapid Library Kit contents lhandley 454 Pyrosequencing 2 05-03-2010 12:34 PM

Thread Tools
Old 02-21-2017, 02:44 AM   #1
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:

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

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!

rwan is offline   Reply With Quote
Old 01-26-2019, 05:39 PM   #2
Junior Member
Location: Australia

Join Date: May 2014
Posts: 2

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:

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)

# 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

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 05:52 PM.

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