Thursday, January 16, 2014

ApE on pMSH2, and mutant identification

Tools-> Align
Align yeastMSH2 CDS (remove last codon of TAA) to plasmid pMSH2 sequence.
There is a gap in the alignment, which was suggested to be the HA tag by Dr. Wang.

http://en.wikipedia.org/wiki/HA-tag

Edit -> Select
Select from 3378 to 6302 MSH2 CDS for 975AA
New Feature, feature type -> CDS

enzymes, Graphic map



The same method can be used to identify mutant msh2 ORF.  Translated mutant ORF can be used to align with WT and identify mutations.



Resources on apE (a plasmid editor)



http://bcrc.bio.umass.edu/intro/content/guide-ape-plasmid-editor-application

Tuesday, January 14, 2014

writing notes

apply something to doing something

compare to and with

vowels and consonants
adjectives, adverbs, articles, clauses, pronouns


seek help (not helps) from the instructor. 

Appropriate 

Tense

weighted vs waited

Students have problems with spelling

Shimon Gibson, an American archaeologist who was not involved in the dig, said the find was truly amazing, less because of its Roman origins than for its precious nature.

Introduction introductory
veracity

More than one method IS (not are) used.  

Different kind of feedback (no plural form)

commensurate with: equal in measure or extent with sth

Inte(:i)grate inte(:e)grity

Sludge

attenuate, mitigate, weaken, decrease, 

calibrate

spread, spread, spread

esoteric--understood by only a group of people

illude: to deceive
allude: to mention indirectly

undecamic complex ??
facetious

formal members -- formally speaking
this is the same as somthing (a noun);   this is same as we did last time (a sentence)
misleading, not "miss leading"
lose loose
cotton (catn, not corton)
a smattering of Americans and swarms of executives from China,
jury vs jewelry
parabolic
atrium
devin - david
spun down
assist in doing sth
impose on you
lantern
to reckon with
network
recite recitation
stultify
constipation
ballute
connotation

labatory not labatorial

cash == cache

produce product
analyze analysis
subsequent  's&b-si-kw&nt <-> sequent
aerobic, anaerobic
senescence
philadelphia
n
red, retrograde
conducive work environment
network
phone [' fOn]

nonsignificant
principal investigator, school principal
inform somebody of doing something
consider of doing something

dissension 



WORD format for Respondus


Questions are numbered 1, 2, 3, ...
Answers are numbered A, B, C, D, ...




Tips: It appears format such as tab, parenthesis, space should be as consistent as possible for Respondus to work properly.

20140921. Format with extra line space in DOCX seemed to cause problem.


https://php.radford.edu/~knowledge/lore/attachment.php?id=60‎

Paper activity for serial dilutions

See also youtube demo at
http://www.youtube.com/watch?v=_araJt0GOvU

Make colored copies of graphing papers: red, blue, and white.

Basic idea: 1 cm2 of paper = 1 part of Things or water.
Red papers represent Things
Blue papers represent water.
White papers are containers.

For 10X red stock:
Draw a 20 parts rectangle in a white graphing paper. This is volume of the 10X stock solution.
Cut 10 part red and 10 part blue paper to fill the space.
The concentration of this solution is 50% red.




To make 1X 20 parts solution, we need 2 parts of 10X. The 2 parts of 10X contain 1 part of red and 1 part of blue (water).
Draw a 20 parts rectangle, cut 1 part of red and 1 part of blue from the 10X stock area, and move to the 1X area. The remaining area of the 1X stock is 18 parts and should be filled with water (blue papers).
The concentration of this 1X solution is 5% red.



To make 0.1X 20 parts solution, we need 2 parts of 1X which contains 2x5%=0.1 part of red and 1.9 parts of blue (water). The concentration of this solution is 0.5% red.



-----------------------The older version,  v1---------------
Make colored copies of graph papers: red, blue, and white.

Basic idea: 1 cm2 of paper = 1 part of things or water

10X red stock: 10 cm2 red paper + 10 cm2 white paper.
The concentration of this solution is 50% red, and its total volume is 20 parts.

5X blue stock: 5 cm2 blue paper + 15 cm2 white paper.
The concentration of this solution is 25% blue, and its total volume is 20 parts.

Exercise 1: To make a volume of 20 parts solution of 1X red and 1X blue, we need 1 part of red and 1 part of blue: 
 1. Use scissor to cut 1 part (1cm2) of red and 1 part (1cm2) of water  from 10X red stock, add to an empty beaker labelled with "1X red, 1X blue".
  2. Use scissor to cut 1 part (1cm2) of blue and 3 part of (3 cm2) of water from 5X blue stock, add to the '1X red 1Xblue' beaker.
  3. How much water should we add?
  20 - 1(red) - 1(water) - 1 (blue) - 3 (water) = 14 parts of water.
This 1X solution should contain 1cm2 red, 1cm2 blue, and 18 cm2 water. 


Exercise 2: To make a 1/10 X solution in a volume of 50 parts: 
1. Take 10 part of 1X: Cut 0.5 part red, 0.5 part blue, 9 part of water from 1X stocks
2. Add 50 - 0.5 - 0.5 - 9 = 40 part of water.

Materials needed: Three beakers; 1 piece of red graph paper, 1 piece of blue graph paper, 3 pieces of white graph papers; 1 Scissor.

H2O2-LOH, strain-averaged data, distribution of Cv and Cb.

Distribution of Cv and Cb in yeast natural isolates

Stain-averaged data are in file "LOHH2O2_averaged20131210_v1.csv".  These data were obtained by supervised gnls fitting.



Distribution of H2O2-viability midpoints (Cv) :
Largest change is 0.17/0.0065 = 26 fold
Histogram of H2O2-viability is:



Distribution of H2O2-LOH midpoints (Cb) :
Largest change is 0.086/0.0065 = 13 fold.
Histogram H2O2-LOH is:

Working directory is   ~/projects/0.LOH_H2O2_2012-master/analysis
Script is _3b.2013Dec10.summarizeFiting.H2O2LOH.R



*** Useful R tips



Read csv is much faster than xlsx.

tb = read.csv(fullFileName, colClasses=c("character",NA, NA, "character", rep("numeric",8 ), NA));


options(echo=TRUE) # if you want see commands in output file
args <- commandArgs(trailingOnly = TRUE)print(args)
# trailingOnly=TRUE means that only your arguments are returned, check:
# print(commandsArgs(trailingOnly=FALSE))i = as.integer(args[1])
j = as.integer(args[2])
x = seq(i, j)
print(x)

R -f R-args.R --args 2 5
Rscript file 

#from lower case to upper case
chartr(old, new, x)
tolower(x)
toupper(x)

casefold(x, upper = FALSE)

    require(stringr)
    conditions$media[r] = str_replace( conditions$media[r], "\\/", "")


tb$AssignmentTotal= apply(tb[, assignments], 1, FUN=function(x){sum(x,na.rm=T)} )


http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-create-rotated-axis-labels_003f

cumsum()
with()

R -f filename



axis( 2, at=pretty(tbf$s), tcl=0.2, las=2 )  #rotate axis labels



text( tb$G + 0.01*nchar(tb$strain)/4, log10(tb$R0)-0.1*nchar(tb$strain)/4, tb$strain, pos=3)


layout(mat, heights= c( 1.15, rep(1, nrow(mat)-2), 1.2) );
par(mar=c(5.1,4.1,4.1,2.1)
http://www.r-bloggers.com/setting-graph-margins-in-r-using-the-par-function-and-lots-of-cow-milk/

 text ( aa, bb, t, cex=0.8);

####aplha
names(fit)[ grep("alpha", names(fit))]
fit_alpha_tb = data.frame( t( fit[, grep("alpha", names(fit)) ]))
rownames(fit_alpha_tb) = names(fit)[grep("alpha", names(fit))]
fit_alpha_tb$names = gsub("_.*", "", rownames(fit_alpha_tb))


library(RColorBrewer);
#hmcol = colorRampPalette(brewer.pal(5,"RdBu"))(8);
hmcol = colorRampPalette(brewer.pal(3,"Blues"))(8);



format(Sys.time(), "%a %b %d %H:%M:%S %Y")
format(Sys.time(), "%Y%b%d_%H%M%S")

 
 
#regular expression 
require(org.Sc.sgd.db)
x <- org.Sc.sgdALIAS
ls(x)[grep("^Y..\\d{3}", ls(x))]
 
http://www.regular-expressions.info/rlanguage.html
http://www.r-bloggers.com/regular-expressions-in-r-vs-rstudio/


list.files for the contents of a directory.
normalizePath for a ‘canonical’ path name.

(WD <- getwd())
if (!is.null(WD)) setwd(WD)


require(xlsx) # read Excel in R.

Usage

! x
x & y
x && y
x | y
x || y
xor(x, y)


rm(list=ls() );



unlist(strsplit("a.b.c", "\\."))
-----
str(x)
attributes(x)
--------------
outer( month.abb, 1999:2003, FUn="paster");

Letters <- c( LETTERS, letters);
Letters[ ! sapply(Letters, function(xx) exists(xx) ) ]; # anonymous function as a wrapper for a primitive function

------------
 legend(100,60, seq(100,200,1), lty=1) # line legends

  Library(MASS); example(Skye); #tenary plot

 library(help = survivial)   

ColorBrewer.org

useful comnds:
x11; factor; relevel; class; loess; contour; is.element; math %in%; grep; sample; nrow; 
grepmisc: hist2d
url()
---
class and object
CA@a[1]

----

test1 <- list( time= c(4, 3,1,1,2,2,3),
  status=c(1,NA,1,0,1,1,0),
  x= c(0, 2,1,1,1,0,0),
  sex= c(0, 0,0,0,1,1,1))
coxph( Surv(time, status) ~ x + strata(sex), test1) #stratified model

----
delete NA form matrix

 > x<-matrix(1:16,4,4)
 > x[col(x)>=row(x)]<-NA
 > x[,! apply(x,2,function(x) all(is.na(x))) ]
     [,1] [,2] [,3]
[1,]   NA   NA   NA
[2,]    2   NA   NA
[3,]    3    7   NA
[4,]    4    8   12

----
? R/Splus Perl interface   RSperl
? R Pythong interface Rpy Rpython
not in CRAN
----
date.grouping <- function(d) {
  # for ea date in d calculate date beginning 6 month period which contains it
  mat <- matrix(as.numeric(unlist(strsplit(as.character(d),"-"))),nr=2)
  f <- function(x) do.call( "ISOdate", as.list(x) )
  POSIXct.dates <- apply(rbind(mat,1),2,f) + ISOdate(1970,1,1)
  breaks <- c(seq(from=min(POSIXct.dates), to=max(POSIXct.dates), by="6 mo"), Inf)
  format( as.POSIXct( cut( POSIXct.dates, breaks, include.lowest=T )), "%Y-%m" ) }

----
nonlinear regression
library(nls)
----
http://www.bioconductor.org/
----
library(lattice)
----
persp()
----
las=1 or 2
You can use the graphics parameter "srt" to rotate displayed text by a specified number of degrees,
 e.g. srt=45 to put it on an angle, srt=90 to put it vertical.  

----
cnams = dimnames(aa)[[2]]

cnams[which(cnams == 'blah3.Mg')] = 'Mg (%)'
...
dimnames(aa)[[2]] = cnams
----
eval(substitute(lf <- locfit(~s, data=age), list(s=s)))
------
  sub=sort(sample(x,200, replace=F))
  postscript("try.ps")
  matplot(x[sub],y[sub,],type="l",lwd=5)     
  dev.off()

-----
>Does anyone know if R has the functionality to calculate a simple 
>moving average. I cant seem to find it in the help menu.

filter in library ts. does filter() do what you need?
Or look at the 'running' function in the gregmisc package.


moving.average <- 
function(x, k) { 
 n <- length(x) 
 y <- rep(0, n) 
 for (i in (1+k):n) 
   y[i] <- mean(x[(i-k):i]) 
 return(y)
 } 

----
tree packages
----

# Create an Example Data Frame Containing Car x Color data, with long car names 
carnames <- c("BMW: High End, German",
              "Renault: Medium End, French",
              "Mercedes: High End, German", 
              "Seat: Imaginary, Unknown Producer")
carcolors <- c("red","white","silver","green")
datavals <- round(rnorm(16, mean=100, sd=60),1)
data <- data.frame(Car=rep(carnames,4),
                   Color=rep(carcolors, c(4,4,4,4) ),
                   Value=datavals )

# generate balloon plot with default scaling, the column labels will overlap 
# balloonplot( data$Color, data$Car, data$Value)


# try again, with column labels rodated 90 degrees, and given more space 
balloonplot( data$Car, data$Color, data$Value, colmar=3, colsrt=90)



----

Here is a very rough addlogo() using pixmap:

"addlogo" <- function(x, y, pixmap) {
    if (is.list(x)) {
        y <- x$y
        x <- x$x
    }
    else if (missing(y)) 
        stop("missing y")
    if (!is.numeric(x) || !is.numeric(y)) 
        stop("non-numeric coordinates")
    if ((nx <- length(x)) <= 1 || nx != length(y) || nx > 2) 
        stop("invalid coordinate lengths")
    pixmap@bbox[1] <- x[1]
    pixmap@bbox[2] <- y[1]
    pixmap@bbox[3] <- x[2]
    pixmap@bbox[4] <- y[2]
    pixmap@cellres[1] <- (pixmap@bbox[3] - pixmap@bbox[1]) / pixmap@size[2]
    pixmap@cellres[2] <- (pixmap@bbox[4] - pixmap@bbox[2]) / pixmap@size[1]
    plot(pixmap, add=TRUE)
    invisible(pixmap)
}

which will work with locator() too. To maintain aspect, it shouldn't alter 
the relative cell resolutions, and should just use the new x or y, bur 
this is the general case. The handling of the location of the logo is 
copied & pasted from legend().



----
x <- readLines(myfile)
strsplit(substring(x,8),split="")
----



Monday, January 13, 2014

Sharing ipad screen on an Apple laptop

Air server

On ipad, look for 'Airplay' icon in the application panel by double-clicking home button


Konical Minotla c745 osX 10.6.8 install, failed.

http://onyxweb.mykonicaminolta.com/OneStopProductSupport?productId=1487




The install basically hangs in the above window..., ....

How to write lab notes

Key elements:
Date
Title of experiments
Names of all members
Aims,
Materials, methods and procedures, such as sequences of primers.
Results and analysis, such as pictures of gels, plate, colony counts, etc. Lanes in gels should be labeled.
Summary/Conclusions
References


Relevant links:
http://ecee.colorado.edu/~mcleod/teaching/ugol/references/Good%20Lab%20Notebooks%20by%20Carter.pdf
 
http://misterguch.brinkster.net/sept2000.pdf

Sample notebooks
http://hongqinlab.blogspot.com/2012_02_01_archive.html
http://glanglab.com/notebooks.html
http://en.wikipedia.org/wiki/Open_notebook_science#cite_note-usefulchem.wikispaces-8

Gene Ontology dataset


ftp://ftp.ebi.ac.uk/pub/databases/GO/goa/


Friday, January 10, 2014

Lotusnote traveler, iPad/iPhone


Pearson Chi-square test with specified probability using chisq.test() in R


chisq.test function in R


> chisq.test
function (x, y = NULL, correct = TRUE, p = rep(1/length(x), length(x)),
    rescale.p = FALSE, simulate.p.value = FALSE, B = 2000)
{
    DNAME <- deparse(substitute(x))
    if (is.data.frame(x))
        x <- as.matrix(x)
    if (is.matrix(x)) {
        if (min(dim(x)) == 1L)
            x <- as.vector(x)
    }
    if (!is.matrix(x) && !is.null(y)) {
        if (length(x) != length(y))
            stop("'x' and 'y' must have the same length")
        DNAME2 <- deparse(substitute(y))
        xname <- if (length(DNAME) > 1L || nchar(DNAME, "w") >
            30)
            ""
        else DNAME
        yname <- if (length(DNAME2) > 1L || nchar(DNAME2, "w") >
            30)
            ""
        else DNAME2
        OK <- complete.cases(x, y)
        x <- factor(x[OK])
        y <- factor(y[OK])
        if ((nlevels(x) < 2L) || (nlevels(y) < 2L))
            stop("'x' and 'y' must have at least 2 levels")
        x <- table(x, y)
        names(dimnames(x)) <- c(xname, yname)
        DNAME <- paste(paste(DNAME, collapse = "\n"), "and",
            paste(DNAME2, collapse = "\n"))
    }
    if (any(x < 0) || any(is.na(x)))
        stop("all entries of 'x' must be nonnegative and finite")
    if ((n <- sum(x)) == 0)
        stop("at least one entry of 'x' must be positive")
    if (simulate.p.value) {
        setMETH <- function() METHOD <<- paste(METHOD, "with simulated p-value\n\t (based on",
            B, "replicates)")
        almost.1 <- 1 - 64 * .Machine$double.eps
    }
    if (is.matrix(x)) {
        METHOD <- "Pearson's Chi-squared test"
        nr <- nrow(x)
        nc <- ncol(x)
        sr <- rowSums(x)
        sc <- colSums(x)
        E <- outer(sr, sc, "*")/n
        v <- function(r, c, n) c * r * (n - r) * (n - c)/n^3
        V <- outer(sr, sc, v, n)
        dimnames(E) <- dimnames(x)
        if (simulate.p.value && all(sr > 0) && all(sc > 0)) {
            setMETH()
            tmp <- .C(C_chisqsim, as.integer(nr), as.integer(nc),
                as.integer(sr), as.integer(sc), as.integer(n),
                as.integer(B), as.double(E), integer(nr * nc),
                double(n + 1), integer(nc), results = double(B))
            STATISTIC <- sum(sort((x - E)^2/E, decreasing = TRUE)) #Pearson chisq
            PARAMETER <- NA
            PVAL <- (1 + sum(tmp$results >= almost.1 * STATISTIC))/(B +
                1)
        }
        else {
            if (simulate.p.value)
                warning("cannot compute simulated p-value with zero marginals")
            if (correct && nrow(x) == 2 && ncol(x) == 2) {
                YATES <- min(0.5, abs(x - E))
                if (YATES > 0)
                  METHOD <- paste(METHOD, "with Yates' continuity correction")
            }
            else YATES <- 0
            STATISTIC <- sum((abs(x - E) - YATES)^2/E)
            PARAMETER <- (nr - 1) * (nc - 1)
            PVAL <- pchisq(STATISTIC, PARAMETER, lower.tail = FALSE)
        }
    }
    else {
        if (length(x) == 1L)
            stop("'x' must at least have 2 elements")
        if (length(x) != length(p))
            stop("'x' and 'p' must have the same number of elements")
        if (any(p < 0))
            stop("probabilities must be non-negative.")
        if (abs(sum(p) - 1) > sqrt(.Machine$double.eps)) {
            if (rescale.p)
                p <- p/sum(p)
            else stop("probabilities must sum to 1.")
        }
        METHOD <- "Chi-squared test for given probabilities"
        E <- n * p
        V <- n * p * (1 - p)
        names(E) <- names(x)
        STATISTIC <- sum((x - E)^2/E)#Pearson chi-sq with input p
        if (simulate.p.value) {
            setMETH()
            nx <- length(x)
            sm <- matrix(sample.int(nx, B * n, TRUE, prob = p),
                nrow = n)
            ss <- apply(sm, 2L, function(x, E, k) {
                sum((table(factor(x, levels = 1L:k)) - E)^2/E)
            }, E = E, k = nx)
            PARAMETER <- NA
            PVAL <- (1 + sum(ss >= almost.1 * STATISTIC))/(B +
                1)
        }
        else {
            PARAMETER <- length(x) - 1
            PVAL <- pchisq(STATISTIC, PARAMETER, lower.tail = FALSE)
        }
    }
    names(STATISTIC) <- "X-squared"
    names(PARAMETER) <- "df"
    if (any(E < 5) && is.finite(PARAMETER))
        warning("Chi-squared approximation may be incorrect")

    structure(list(statistic = STATISTIC, parameter = PARAMETER,
        p.value = PVAL, method = METHOD, data.name = DNAME, observed = x,
        expected = E, residuals = (x - E)/sqrt(E), stdres = (x -
            E)/sqrt(V)), class = "htest")
}

Thursday, January 9, 2014