This file contains 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
# | |
# Steve Pittard - [email protected], 03/19/12 | |
# Code to illustrate motivations for using apply function | |
# | |
# See www.bimcore.emory.edu/bbseries for slides and code downloads | |
# | |
# References include: | |
# http://statland.org/R/R/Rpulse2.htm , http://www.cyclismo.org/tutorial/R/tables.html#manipulations | |
# http://nsaunders.wordpress.com/2010/08/20/a-brief-introduction-to-apply-in-r/ | |
# |
This file contains 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
with() | |
within() | |
round(x, n) # rounds x to n decimal places | |
ceiling(x) # vector x of smallest integers > x | |
floor(x) # vector x of largest interger < x | |
as.integer(x) # truncates real x to integers (compare to round(x, 0) | |
as.integer(x < cutpoint) # vector x of 0 if less than cutpoint, 1 if greater than cutpoint) |
This file contains 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
$ git init | |
# Print & Set Some Basic Config Variables (Global) | |
$ git config --global user.email | |
$ git config --global user.name | |
$ git config --global user.email "[email protected]" | |
$ git config --global user.name "My Name" |
This file contains 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
1:10 | |
c(1, 2, 3, 4) | |
seq(1, 10, 1) | |
seq(from=1, to=10, by=1) | |
sequence(c(10, 5)) | |
seq(along.with=myData) # makes seq of 1:length(myData)) | |
seq(10, along.with=myData) # makes seq of 10:length(myData)) | |
seq(from=2, length.out=10) | |
rep(x, times = 1, length.out = NA, each = 1) |
This file contains 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
# ggplot2 implements the idea of a "grammar of graphics". The grammar implemented | |
# by ggplot2 could be summarized as follows: | |
# | |
# plot: coord, scale, facet(?) + layers | |
# layer: data mapping stat geom position? | |
# | |
# A plot is defined by a coordinate system (coord), one or more scales (scale), an | |
# optional faceting specification (facet), and one or more layers (layer). A layer | |
# is defined as an R data frame (data), a specification mapping columns of that | |
# frame into aesthetic properties (mapping), a statistical approach to summarize |
This file contains 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
### MATPLOTLIBRC FORMAT | |
# This is a sample matplotlib configuration file - you can find a copy | |
# of it on your system in | |
# site-packages/matplotlib/mpl-data/matplotlibrc. If you edit it | |
# there, please note that it will be overridden in your next install. | |
# If you want to keep a permanent local copy that will not be | |
# over-written, place it in HOME/.matplotlib/matplotlibrc (unix/linux | |
# like systems) and C:\Documents and Settings\yourname\.matplotlib | |
# (win32 systems). |
This file contains 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('prep_data.R') | |
library(vegan) | |
library(RColorBrewer) | |
# select env/process data | |
meta <- data[ , 1:( which( names(data) == "amplib_id" )) ] | |
env <- data[ , ( which( names(data) == "primary_sed" )):( which( names(data) == "otu_0" ) - 1) ] | |
otu <- as.matrix(data[, (which(names(data) == "otu_0" )):ncol(data) ]) | |
summary(env) |
This file contains 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
# infile is 'rename_mapping.txt' tab-sep: oldname newname | |
# ext of file to be replace can be specified | |
with open('rename_mapping.txt', 'r') as fh: | |
map = { line.strip().split()[0]:line.strip().split()[1] for line in fh.readlines() } | |
oldnames = !ls *.fastq.gz | |
for oldname in oldnames: | |
if oldname in map: | |
newname = map[oldname] | |
!mv $oldname $newname |
This file contains 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
# http://timotheepoisot.fr/2013/02/17/stacked-barcharts/ | |
library(RColorBrewer) | |
Abund = round(matrix(runif(200,0,1),nc=10),2) | |
Abund = Abund/max(Abund) | |
rownames(Abund) = LETTERS[c(1:nrow(Abund))] | |
colnames(Abund) = letters[c(1:ncol(Abund))] | |
This file contains 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
# Dereplication | |
usearch --sort reads.fa --output reads.sorted.fa | |
usearch --derep_fullseq --cluster reads.sorted.fa --seedsout unique.fa [--uc results.uc] [--sizeoout] [--minsize n] [--slots n] [--w wordlength] | |
usearch --derep_fullseq --cluster reads.sorted.fa --seedsout unique.fa --uc results.uc |