Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dritoshi committed Jun 8, 2011
0 parents commit bf761a4
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 0 deletions.
Binary file added 1439627_at.exprgraph.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 1439627_at.exprmap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 1439627_at.switchgraph.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 1439627_at.switchmap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions README
@@ -0,0 +1,26 @@
BrainStars API client for R

Itoshi NIKAIDO <dritoshi@gmail.com>
Copyright (C) 2009. Itoshi NIKAIDO. GPL 2

This R library can search and get gene expression data and plots
from BrainStars (or B*, http://brainstars.org/).

BrainStars is a quantitative expression database of the adult
mouse brain. The database has genome-wide expression profile at 51
adult mouse CNS regions.

For 51 CNS regions, slices (0.5-mm thick) of mouse brain were cut on a
Mouse Brain Matrix, frozen, and the specific regions were punched out
bilaterally with a microdissecting needle (gauge 0.5 mm) under a
stereomicroscope. For each region, we took samples every 4 hours,
starting at ZT0 (Zeitgaber time 0; the time of lights on), for 24
hours (6 time-point samples for each region), and we pooled the
samples from the different time points. We independently sampled each
region twice (n=2).

These samples were purified their RNA, and measured with Affymetrix
GeneChip Mouse Genome 430 2.0 arrays. Expression values were then
summarized with the RMA method. After several analysis with the
expression data, the data and analysis results were stored in the
BrainStars database.
6 changes: 6 additions & 0 deletions Rakefile
@@ -0,0 +1,6 @@
task :default => [:demo]

desc "Run demo"
task :demo do
sh "R -q -f run_brainstars.r"
end
74 changes: 74 additions & 0 deletions brainstars.r
@@ -0,0 +1,74 @@
#
# R Library for BrainStars http://brainstars.org/
#
# Itoshi NIKAIDO <dritoshi@gmail.com>
# Copyright (C) 2009. Itoshi NIKAIDO. GPL 2
#

getBrainStarsExpression <- function(gene) {
base.url <- "http://brainstars.org/probeset/"
url.options <- "/exprvalues.csv"
url <- paste(base.url, gene, url.options, sep="")

expr <- read.csv(url, row.names=1)
return(expr)
}

getBrainStarsFigure <- function(gene, url.option) {
require("RCurl")

base.url <- "http://brainstars.org/probeset/"
url.option.list <- c("exprgraph", "exprmap", "switchgraph", "switchhist", "switchmap")

if (sum(url.option.list == url.option) != 1) {
error.meg <- "Specify figure type."
error.meg <- paste(error.meg, paste(url.option.list, collapse=", "))
stop(warn=error.meg)
}

cat("Downloading...\n")
url <- paste(base.url, gene, "/", url.option, ".png", sep="")
file.name <- paste(gene, ".", url.option, ".png", sep="")
plot <- getBinaryURL(url)
cat("Done.\n")

writeBin(plot, file.name)
invisible(plot)
}

getBrainStarsSearch <- function(keyword) {
require("RCurl")

base.url <- "http://brainstars.org/search/"

# if (sum(keyword) != 1) {
# error.meg <- "Input keyword type."
# error.meg <- paste(error.meg, paste(keyword, collapse=", "))
# stop(warn=error.meg)
# }

cat("Downloading...\n")
url <- paste(base.url, keyword, sep="")
cat("Done.\n")
results <- getURL(url)
results <- unlist(strsplit(results, "\n"))
return(results)

# writeBin(plot, file.name)
# invisible(plot)
}

getBrainStarsMarker <- function(keyword) {
require("RCurl")

base.url <- "http://brainstars.org/marker/"
json.option <- "?content-type=application/json"

cat("Downloading...\n")
url <- paste(base.url, keyword, json.option, sep="")
cat(url, "\n")
cat("Done.\n")
results <- getURL(url)
#results <- unlist(strsplit(results, "\n"))
return(results)
}
22 changes: 22 additions & 0 deletions run_brainstars.r
@@ -0,0 +1,22 @@
source("brainstars.r")

# Search API
receptors <- getBrainStarsSearch("receptor/10,5")
num.receptors <- getBrainStarsSearch("receptor/count")
cat(receptors, "\n")
cat(num.receptors, "\n")

# Marker API
r.json <- getBrainStarsMarker("high/LS/count")
cat(r.json, "\n")

# Expression API
expression <- getBrainStarsExpression("1439627_at")
print(expression)

# Graph API
getBrainStarsFigure("1439627_at", "exprgraph")
getBrainStarsFigure("1439627_at", "exprmap")
getBrainStarsFigure("1439627_at", "switchgraph")
#getBrainStarsFigure("1439627_at", "switchhist")
getBrainStarsFigure("1439627_at", "switchmap")

0 comments on commit bf761a4

Please sign in to comment.