Skip to content

Instantly share code, notes, and snippets.

@bobthecat
Created May 15, 2012 22:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save bobthecat/2705715 to your computer and use it in GitHub Desktop.
Save bobthecat/2705715 to your computer and use it in GitHub Desktop.
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
Copy link

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
Copy link
Author

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
Copy link

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