#Demo for com call
library(XML)
load_all("~/src/rentrez")
library(rcrossref) | |
add_to_bib <- function(doi, bib="ms.bib", print_ref=TRUE){ | |
ref <- cr_cn(doi) | |
cat("\n", ref, "\n\n", file=bib, append=TRUE) | |
if(print_ref){ | |
cat(ref, "\n") | |
} | |
} |
#Demo for com call
library(XML)
load_all("~/src/rentrez")
From a biostars question about interleaving vectors...
For loops can (but don't have to) be really slow in R, so I wanted to compare answers provided to this question to compare a straightforward for loop approach, to various work arounds to speed the process up.
f_for <- function(a,b){
res <- c()
```{r, echo=FALSE} | |
knitr::opts_knit$set(upload.fun = knitr::imgur_upload, base.url = NULL) | |
``` | |
# and now, all animals and with nested taxonomic ranks | |
So, a few people liked [this example](https://gist.github.com/dwinter/8d7bde0579daf7466508) | |
of using `rentrez` to investigate the taxonomic distribution of sequences in | |
Genbank. I though it might be fun to extend it a little. Specifically: |
#Finding the number of sequence records by taxonomic group
Ricardo wants to know how to find the number of sequence records associated with sub-groups within a given taxon . This example grew a bit too big to make into a comment, so here it is in gist form.
So, let's find out how many DNA sequences are present in genbank for each
library(ape)
data(woodmouse)
#Just the third codon (assuming alignment is in-frame)
woodmouse[, seq(1, ncol(woodmouse), by=3) ]
## 15 DNA sequences in binary format stored in a matrix.
##
#Notes from ipython notebook lab talk
##Introduction
ipython
is an alternative shell for python which is aimed at meeting the needs of interactive/scientific computing. One of it's coolest features is the ipython notebook
, which allows users to combined styled text, fancy looking maths, code and the results of that codes execution.
Although it has "python" in the name, the notebook is not restricted to that programing language. "Magic" functions allow users to execute different languages in an "ipython" notebook, and other languages (including Julia, Haskell and Ruby...) can be the default language of a whole notebook. In fact, the notebook project recently changed its name to jupyter
(from JUlia PYthon and R -- the "languages of open science").
The notebook is especially helpful for recording exploritory/interactive analyses and plots made in bioinformatics/computational biology.
##Install
library(ggplot2) | |
library(grid) | |
make_normal_cont <- function(Ea, n=100, steps=11){ | |
Ut <- 0.2/Ea | |
x <- rma_normal(n, Ea, Ea/10, 1e-4, Ut) | |
effect_sizes <- seq(1e-4, Ea * 2, length.out=steps) | |
mus <- seq(Ut - Ut/1.2, Ut *3, length.out=steps) | |
res <- expand.grid(mean_effect = effect_sizes, Ut=mus) | |
res$Lik <- apply(res, 1, function(r) dma_normal(x, a=r[1], Va =r[1]/50, |