Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/perl -w
use strict;
# Given properly formatted herbarium records, this script will produce two
# datasets of equal size for two time periods. From these, for each species,
# the mean value of each time period is calculated. The script outputs a
# tab-delimited table of columns for species, mean value of the first time
# period, and the mean value of the second time period. This table can be used
# to perform classical statistical tests in R. Justification for the technique
# is provided below.
## read in our data
data<-read.table("binned.ele",head=T)
## how are our variables named?
names(data)
## attach them
attach(data)
## are the sample variances significantly different?
var.test(BEFORE,AFTER)
## they're not, so we can't use a t-test
## we use the wilcoxon's rank test
[1] "SPECIES" "BEFORE" "AFTER"
F test to compare two variances
data: BEFORE and AFTER
F = 1.0636, num df = 45555, denom df = 45555, p-value = 4.796e-11
alternative hypothesis: true ratio of variances is not equal to 1
95 percent confidence interval:
1.044220 1.083289
sample estimates:
#!/usr/bin/perl
use warnings;
use strict;
my $readsA = '5';
my $readsT = '4';
my $readsG = '0';
my $readsC = '0';
my $error_rate = '0.001';
@grassa
grassa / stdin.c
Created August 31, 2011 18:45
parse tab delimited standard input
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* The block below is included so that the program will compile on the macintosh, which lacks gnu's getline. Compilation produces a non-fatal warning*/
/* This code is public domain -- Will Hartung 4/9/09 -from http://stackoverflow.com/questions/735126/are-there-alternate-implementations-of-gnu-getline-interface*/
size_t getline(char **lineptr, size_t *n, FILE *stream) {
char *bufptr = NULL;
char *p = bufptr;
size_t size;
#include <stdio.h>
#include <math.h>
long fact(int n){
if(n == 0){
return 1;
}
else{
return n * fact(n-1);
}
}
#!/usr/bin/Rscript
args <- commandArgs(trailingOnly = TRUE)
lg<-args[1]
infile<-args[2]
assembly<-args[3]
bpmax<-as.integer(args[4])
genesinfile<-args[5]
pngout<-paste(infile,".genes.png",sep="")
header<-paste(lg,"",sep="\n")
dat<-read.table(infile,head=T)