Main Page

From BCF's Genetics Wiki

Jump to: navigation, search

Contents

[edit] Update

Anonymous edits and anonymous account creation have been disabled as a result of link-spam. If you would like an account please locate the email address for Brant Faircloth and email me.

[edit] R

95% Kernel Home Range exported to ArcGIS:

> drv = MySQL()
> con = dbConnect(drv, group='bonasa')
> rs <- dbSendQuery(con, "select bird_id,x_coord,y_coord from ttrs_breeding_telemetry where year(date)=2001")
> data <- fetch(rs, n = -1)
> loc = data[, c('x_coord','y_coord')]
> id = data[, c('bird_id')]
> my.grid <- ascgen(loc, cellsize=15)
> my.grid
> ud = kernelUD(loc,id, h = ,grid=my.grid,same4all=TRUE)
> ver = getverticeshr(ud,95)
> plot(ver)
> out = kver2shapefile(ver)
> write.shapefile(out,"2001_95Kernel",arcgis=TRUE)

In ArcGIS:

1.)  Repair geometry on shapefile
2.) Dissolve on name field

[edit] SQL

Subtract some days from a date:

SELECT DISTINCT(brood1), date, week(date) AS week, date_sub(date,INTERVAL 22 day) AS incubation FROM ttrs_2001_brood_genetics;

Output data with header:

SELECT 'bird_id','P1A7A','P1A7B','P1F2A','P1F2B','P1F3A','P1F3B','P1H12A','P1H12B','P2D7A','P2D7B','PA12AA','PA12AB','PA12GA','PA12GB','PA1CA','PA1CB','PA1FA','PA1FB','PA3EA','PA3EB',
'PA3FA','PA3FB','PA3GA','PA3GB','PA5FA','PA5FB','PBA4A','PBA4B','PCF5A','PCF5B','PBH5A','PBH5B' UNION SELECT * INTO OUTFILE '/home/bcf/dbaseDown/BuckCreek.csv' FIELDS
TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' FROM genotypes WHERE bird_id IN (SELECT bird_id FROM resident03 ORDER BY RAND());

Find duplicate records:

SELECT bird_id,count(*) AS n FROM ttrs_2003_status GROUP BY bird_id HAVING  n > 1;

FInd duplicate chicks records with same colors:

SELECT bird_id,box,count(*) AS n FROM sample_sheets WHERE bird_id REGEXP '[[:alpha:]]+' GROUP BY bird_id HAVING  n > 1 ORDER BY bird_id;

Get mating bird records from database, provided extra info. has been added (2003):

SELECT count(*) FROM ttrs_2003_status WHERE (dead > '2003-04-15' OR dead IS NULL) AND sex = 'male';
SELECT count(*) FROM ttrs_2003_status WHERE (dead > '2003-04-15' OR dead IS NULL) AND sex = 'female';

Get female birds with genetics records given the above:

SELECT bird_id FROM 03_provisional WHERE bird_id IN (SELECT bird_id FROM ttrs_2003_status WHERE (dead > '2003-04-15' OR dead IS NULL) AND sex = 'female') INTO OUTFILE '/home/bcf/dbaseDown/2003_females.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"';

Get male birds with genetics records given the above:

SELECT bird_id FROM 03_provisional WHERE bird_id IN (SELECT bird_id FROM ttrs_2003_status WHERE (dead > '2003-04-15' OR dead IS NULL) AND sex = 'male') INTO OUTFILE '/home/bcf/dbaseDown/2003_males.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"';


Get male birds with genetics records given the above:

SELECT bird_id FROM 03_provisional WHERE bird_id IN (SELECT bird_id FROM ttrs_2003_status WHERE (dead > '2003-04-15' OR dead IS NULL) AND sex = 'male' INTO OUTFILE '/home/bcf/dbaseDown/2003_males.csv' FIELDS terminated BY ',');

[edit] Snippets

[edit] Sample without replacement

from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/272884

from numpy import random
 
def sample(n, r):
"Generate r randomly chosen, sorted integers from [0,n)"
rand = random.random
pop = n
for samp in xrange(r, 0, -1):
cumprob = 1.0
x = rand()
while x < cumprob:
cumprob -= cumprob * samp / pop
pop -= 1
yield n-pop-1
 
 
# Example call to select three samples in range(0,10)
>>> list(sample(10, 3))
[2, 7, 8]

[edit] Change nexus format into something useable by Wang relatedness estimator

The following is regex:

(\s\s\s\s\s)|(/+\s\s\s)|(/+\s\s)|(\s\s\s\s)

[edit] Flag all messages as read in mutt

<ctrl-t> ~A ; W N <ctrl-t> ~T

[edit] Lab Programs

This list includes instructions for use and compilation instructions for several programs (some of which were nasty to compile on OS X).

blast

phred

cri-map

Jim Kent Source

[edit] Lab Protocols

Plant Identification

[edit] Postfix/cacert file

  • find out the chain of certificates:
openssl s_client -showcerts -connect <myserver>:<ssl_port>
  • get the CA certificate at the top of the chain (e.g. Thawte, etc.)
  • convert this file to pem format
openssl x509 -in file.cer -inform d -out file.pem
  • fingerprint it
openssl x509 -noout -fingerprint -in ca-certificate-file
  • check fingerprint against some trusted source
  • copy the pem to /etc/postfix/ as cacert.pem
  • ensure that the following line is in /etc/postfix/main.cf: smtp_tls_CAfile = /etc/postfix/cacert.pem

[edit] Pyscopg (Using macports postgresql 8.3)

  • download source for mxDateTime and install
  • configure pyscopg using:
./configure --with-postgres-libraries=/opt/local/lib/postgresql83 \
--with-postgres-includes=/opt/local/include/postgresql83 \
--with-mxdatetime-includes=/Library/Python/2.5/site-packages/mx/DateTime/mxDateTime
  • make
  • sudo make install

[edit] Getting started

Personal tools