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
--- | |
title: rentrez tutorial | |
layout: tutorial | |
packge_version: 0.2.1 | |
--- | |
```{r, eval=TRUE, echo=FALSE} | |
opts_chunk$set(fig.path="../assets/tutorial-images/rentrez/") | |
``` |
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/env python | |
""" | |
Fetch all FASTQ files associated with an SRA ID | |
usage: | |
sra_fetch.py [sra-id] | |
""" |
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
{ | |
"metadata": { | |
"name": "", | |
"signature": "sha256:98f1acba9791082035860796ccf52294670282ba8deb7745219206b5182498d8" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ |
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
gb_acc <- "JF493405" | |
nuc_id <- entrez_search(db="nuccore", term=paste(gb_acc, "[accn]", sep=""))$id | |
tax_links <- entrez_link(db="taxonomy", dbfrom="nuccore", id=nuc_id) | |
tax_summ <- entrez_summary(db="taxonomy", id=tax_links$nuccore_taxonomy) |
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(stringr) | |
library(rjson) | |
geocode <- function(loc_string){ | |
clean_loc <- str_replace_all(str_replace_all(loc_string, "[[:punct:]]", ""), " ", "+") | |
base_url <- "http://maps.googleapis.com/maps/api/geocode/json?address=" | |
loc_url <- paste(base_url, clean_loc, "&sensor=false", sep="") | |
geocode <- fromJSON(paste(readLines(loc_url), collapse="")) | |
if( length(geocode$results) > 0 ){ | |
return(geocode$results[[1]]$geometry$location) |
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(rentrez) #written for devel-version on github | |
fetch_abstract <- function(doi){ | |
search <- entrez_search(term=paste(doi, "[doi]", sep=""), db="pubmed") | |
rec <- parse_pubmed_xml(entrez_fetch(db="pubmed", id=search$ids, rettype="xml")) | |
return(rec$abstract) | |
} | |
fetch_abstract("10.1111/j.1461-0248.2010.01509.x") |
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
import random | |
def shotgun(iterable, size=12): | |
""" """ | |
start = random.choice(range(0, len(iterable)-size)) | |
return(start, iterable[start:start+size]) | |
def paired_end(iterable, read_size=10, gap_size=15): | |
""" """ | |
start = random.choice(range(0, len(iterable)-(read_size+gap_size))) |
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
f <- function(x,y) sin(x)/cos(y) | |
x <- seq(-5,5,0.1) | |
y <- seq(-5,5,0.1) | |
df <- expand.grid(x,y) #all possible combinations of x and y | |
df$value <- apply(df, 1, function(x) f(x[1], x[2])) | |
p <- ggplot(df, aes(Var1,Var2,fill=res>0)) | |
p + geom_raster() |
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
model_diagnostics <- function(modlist, plot=TRUE){ | |
get_param_ranges <- function(x) { | |
res <- apply((sapply(x, posterior.mode)),1,range) | |
rownames(res) <- c("min", "max") | |
return(res) | |
} | |
n <- length(modlist) | |
on.exit(devAskNewPage(devAskNewPage())) #ie send it back the way it was |
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
df1 <- data.frame(x=sample(letters, 20), y=rnorm(20)) | |
df2 <- data.frame(x=sample(letters, 20), z=rnorm(20)) | |
new_df <- merge(df1, df2, all.x=TRUE) | |
matched <- merged[complete.cases(merged),] | |
unmatched <- merged[!complete.cases(merged),] |