This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/perl -w | |
| # | |
| # pubmed_trend.pl | |
| # | |
| # Created by David Ruau on 2011-02-17. | |
| # Department of Pediatrics/Div. System Medicine Stanford University. | |
| # | |
| ##################### USAGE ######################### | |
| # | |
| # Query PubMed with Eutils tools |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| plot_bar <- function(x=sex.pub, linecol="royalblue", cols, addArg=TRUE) { | |
| bp <- barplot(x, col=cols, add=addArg) | |
| fit <- stats::lowess(x, f=1/3) | |
| lines(x=bp, fit$y, col=linecol, lwd=3) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(GEOquery); library(RankProd); library(mouse4302.db) | |
| ## Download the data from GEO | |
| gse12499 <- getGEO('GSE12499',GSEMatrix=TRUE) | |
| e <- exprs(gse12499[[1]]) | |
| dim(e) | |
| [1] 45101 10 | |
| ## Rank Product | |
| eRP <- RP(e[,c(1:3, 7:10)], cl=c(0,0,0,1,1,1,1), rand = 123) | |
| table <- topGene(eRP, cutoff=0.001, method="pfp", logged=TRUE, | |
| logbase=2, gene.names=rownames(e)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| source('source_https.r') | |
| ## You can now source R scripts from GitHub. The RAW URL is needed. | |
| source_https('https://raw.github.com/bobthecat/codebox/master/GO_over.r') | |
| ## Define the universe | |
| library(mouse4302.db) | |
| uniqueId <- unique(as.vector(unlist(as.list(mouse4302ENTREZID)))) | |
| entrezUniverse <- uniqueId[!is.na(uniqueId)] | |
| length(entrezUniverse) | |
| [1] 20877 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(org.Mm.eg.db); library(gplots); library(bioDist) | |
| # get gene in GO cat | |
| gGOcat <- list() | |
| for(i in 1:dim(mrnaGO)[1]){ | |
| gGOcat[[mrnaGO$GOBPID[i]]] <- as.vector(unlist(mget(mrnaGO$GOBPID[i], org.Mm.egGO2ALLEGS))) | |
| } | |
| # filter each GO cat by the genes found to be DE | |
| f <- function(vecGO, vecDE){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| get.ppiNCBI <- function(g.n) { | |
| require(XML) | |
| ppi <- data.frame() | |
| for(i in 1:length(g.n)){ | |
| o <- htmlParse(paste("http://www.ncbi.nlm.nih.gov/gene/", g.n[i], sep='')) | |
| # check if interaction table exists | |
| exist <- length(getNodeSet(o, "//table//th[@id='inter-prod']"))>0 | |
| if(exist){ | |
| p <- getNodeSet(o, "//table") | |
| ## need to know which table is the good one |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ppi <- get.ppiNCBI(head(glist, 20)) | |
| [1] "7 interactions found" | |
| ## Annotate the gene list with Mus musculus metadata | |
| library(org.Mm.eg.db) | |
| ppi$egSymbol <- mget(ppi$egID, envir=org.Mm.egSYMBOL, ifnotfound=NA) | |
| ppi$intID <- mget(ppi$intSymbol, envir=org.Mm.egSYMBOL2EG, ifnotfound=NA) | |
| ppi <- ppi[,c(3,2,1,4)] | |
| ppi | |
| egSymbol intSymbol egID intID | |
| 1 Ifi202b Pou5f1 26388 18999 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library("igraph") | |
| gg <- graph.data.frame(ppi) | |
| plot(gg, | |
| layout = layout.fruchterman.reingold, | |
| vertex.label = V(gg)$name, | |
| vertex.label.color= "black", | |
| edge.arrow.size=0, | |
| edge.curved=FALSE | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require(inline) | |
| require(RcppArmadillo) | |
| ## extract cosine similarity between columns | |
| cosine <- function(x) { | |
| y <- t(x) %*% x | |
| res <- 1 - y / (sqrt(diag(y)) %*% t(sqrt(diag(y)))) | |
| return(res) | |
| } |
OlderNewer