Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
pubmed trend for pain
source('pubmed_trend.r')
sex.pub <- pubmed_trend(search.str = 'Sex+Characteristics[mh] AND Pain[mh]', year.span=1970:2011)
analgesic.pub <- pubmed_trend(search.str = 'Sex+Characteristics[mh] AND Analgesics[mh]', year.span=1970:2011)
source('plot_bar.r')
library("RColorBrewer")
pdf(file='sex_pain.pdf', height=8, width=8)
par(las=1)
colorfunction = colorRampPalette(brewer.pal(9, "Reds"))
mycolors = colorfunction(length(sex.pub))
plot_bar(x=sex.pub, linecol="#525252", cols=mycolors, addArg=FALSE)
colorfunction = colorRampPalette(brewer.pal(9, "Blues"))
mycolors = colorfunction(length(analgesic.pub))
plot_bar(x=analgesic.pub, linecol='black', cols=mycolors, addArg=TRUE)
title('Number of publication per year')
legend('topleft',
legend=c('Sex and Pain', 'Sex and Analgesics'),
fill=c("red", "blue"),
bty="n",
cex=1.1
)
dev.off()
@produnis

This comment has been minimized.

Copy link

@produnis produnis commented May 23, 2012

To make this work on Ubuntu, you need to prepare your system like this:

In Ubuntu, install XML and Curl support.
Otherwise, installation of R-Packages will fail
Open a terminal and type in:

sudo apt-get install libxml2-dev curl libcurl4-openssl-dev

the perl script needs the TGEN-EUtils
download package TGen-EUtils-0.xxx.tar.gz from http://bioinformatics.tgen.org/brunit/downloads/tgen-eutils/
extract it to some place you like, e.g. ~/Downloads/
in terminal go to the extracted folder
type in:

perl Makefile.PL

make

make test

sudo make install

Start R
install packages 'XML', 'RCurl', 'RColorBrewer'
type in:

install.packages(c('XML', 'RCurl', 'RColorBrewer'),dependencies=T)

Now the Script should work
Works at least under Ubuntu 12.04 LTS precise 64
Have fun

@bobthecat

This comment has been minimized.

Copy link
Owner Author

@bobthecat bobthecat commented May 23, 2012

Thanks produnis,
This Gist is part of a blog post available here. http://brainchronicle.blogspot.com/2012/05/using-r-to-graph-subject-trend-in.html

@produnis

This comment has been minimized.

Copy link

@produnis produnis commented May 23, 2012

thx dude,
I read it here http://www.r-bloggers.com/using-r-to-graph-a-subject-trend-in-pubmed/
and it took me some time to explore these steps
:)

great work btw!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.