help() dim(state.x77) state.x77[1:10,] state state.region aggregate(presidents, nf = 1, FUN = mean) y <- c(1:3,7,5)# x <- c(1:3,6:7)# ( ee <- effects(lm(y ~ x)) )# c(round(ee - effects(lm(y+10 ~ I(x-3.8))),3))# just the first is different ee effects(lm(y+10 ~ I(x-3.8))) I(x-3.8) (x-3.8) class(x-3.8) class(I(x-3.8)) lm(y ~ x) x <- 1:5; coef(lm(c(1:3,7,6) ~ x)) memory.profile() format(rep(13.7,3), width=10,nsmall=3) ls() tj <- read.csv(stdin(),comment.char="#") tg<- tj tg td <- tj[,3:ncol(tj)] td rownames(td)<-tj[,1] td h <- hist(td) dim(td) VADeaths barplot(td) class9td) class(td) barplot(as.matrix(td)) barplot(as.matrix(td),beside=T) barplot(as.matrix(td["Daphx_GNO"]),beside=T) barplot(as.matrix(td["Daphx_GNO",]),beside=T) barplot(as.matrix(td["Daphx_GNO",-1]),beside=T) barplot(as.matrix(td[,-1]),beside=T) td[,-1] td[,-1]/td[,1] barplot(as.matrix(td[,-1]/td[,1]),beside=T) setwd("~/Desktop/dspp-work/genomesoft/tandy/") load(".RData") ls() gpa tw1 pe1 <- read.table("pexons.tandynear4.txt", header=T, strip.white=T) dim(pe1) pe1 pe1$species pe1$group pe1$ggroup pe <- pe1 pelev <- grep("NCBI",as.character(pe$ggroup),value=T) pefac <- factor(pe$ggroup, levels=pelev, ordered=T,exclude=NULL) pelev pefac pea <- pe[!is.na(pefac),c(-1,-2)] paste( pe[!is.na(pefac),c(1,2)], sep="") pea pe[!is.na(pefac),c(1,2)] paste( pe[!is.na(pefac),c(1,2)]) paste( as.character(pe[!is.na(pefac),c(1,2)])) pe[!is.na(pefac),1] pe[!is.na(pefac),2] factors(pe[!is.na(pefac),2]) factor(pe[!is.na(pefac),2]) factor(pe[!is.na(pefac),c(1,2)]) colnames(pea) rownames(pea) <- pe[!is.na(pefac),1] # species pea pelev maxgrep("NCBI",as.character(pe$ggroup),value=T) grep("NCBI",as.character(pe$ggroup),value=T) grep("_found",as.character(colnames(pea))) predtitle <- "Pred. exons/species, predictor=" ylabel <- "exon count" tparm <- grep("_found",as.character(colnames(pea))) # 2 4 6 8 10 12 tcols <- c("lightblue", "mistyrose", "lightcyan", "lavender", 2:20) [1:length(tparm)] bpx <- barplot( as.matrix(t( pea[,tparm])),ylab=ylabel, main=predtitle, beside=T, legend=F, col = tcols ) # ylim=c(0,ymax), grep("_found",as.character(colnames(pea))) grep("_found",as.character(colnames(pea)),value=T) grep("!Same",grep("_found",as.character(colnames(pea)),value=T),value=T) grep("_found",colnames(pea)) - grep("Same",colnames(pea)) grep("_found",colnames(pea)) & grep("Same",colnames(pea)) grep("Same",colnames(pea)) grep("_found",colnames(pea)) grep("_found",colnames(pea)) ! grep("Same",colnames(pea)) grep("_found",colnames(pea)) %!% grep("Same",colnames(pea)) grep("_found",colnames(pea)) %*% grep("Same",colnames(pea)) regexpr("_found",colnames(pea)) gregexpr("_found",colnames(pea)) regexpr("_found",colnames(pea)) regexpr("_found",as.character(colnames(pea))) colnames(pea) regexpr("_found",colnames(pea)) regexpr("Same",colnames(pea)) -regexpr("Same",colnames(pea)) -regexpr("Same",colnames(pea))[1] -regexpr("Same",colnames(pea))[1,] -regexpr("Same",colnames(pea))[,1] - regexpr("Same",colnames(pea)) pmatch("Same",colnames(pea)) pmatch("_found",colnames(pea)) pmatch("found",colnames(pea)) pmatch("found",colnames(pea),duplicates.ok=T) grep("_found",colnames(pea)) grep("Same",colnames(pea)) colnames(pea)[1] colnames(pea)["align"] grep("align",colnames(pea)) grep("nxfound",colnames(pea)) grep("found",colnames(pea)) grep("^found",colnames(pea)) pea$align <- pea$align/pea$cdslen pea$nxfound <- pea$nxfound/pea$nexon # tparm <- grep("_found",as.character(colnames(pea))) # 2 4 6 8 10 12 tparm <- c(2,4,6,8,10,15) # 13,17 == align,nxfound tcols <- c("lightblue", "mistyrose", "lightcyan", "lavender", 2:20) [1:length(tparm)] bpx <- barplot( as.matrix(t( pea[,tparm])),ylab=ylabel, main=predtitle, beside=T, legend=F, col = tcols ) # ylim=c(0,ymax), ggroup <- "Gnomon" predtitle <- paste("Pred. exons/species, predictor",ggroup) bpx <- barplot( as.matrix(t( pea[,tparm])),ylab=ylabel, main=predtitle, beside=T, legend=F, col = tcols ) # ylim=c(0,ymax), legend( x="topright", colnames(pea[,tparm]), lwd=3, col=tcols) sppset <- c("dmel","dsec","dsim","dyak","dere","dana","dpse","dper", "dwil","dmoj","dvir","dgri","dappulx","caeele") spat <- paste(sppset,collapse="|") rown <- pe[!is.na(pefac),1] # species rown rown[sppset,] rown sppset1 <- c("dsec","dyak","dere","dpse","dwil","dgri","dappulx") rown[sppset1,] dim(sppset1) length(sppset1) dim(rown) length(rown) order(rown,sppset1) order(sppset1,rown) rown[ order(sppset1,rown) ] pea[ order(sppset1,rown), ] pea[ order(sppset1), ] pea[ sppset1, ] pea <- pe[!is.na(pefac),c(-1,-2)] rown <- pe[!is.na(pefac),1] # species rownames(pea) <- rown pea <- pea[sppset1,] pea pea$align <- pea$align/pea$cdslen pea$nxfound <- pea$nxfound/pea$nexon tparm <- c( 6,8,10,15) # 13,17 == align,nxfound ; 2,4, = far, inside tcols <- c("lightblue", "mistyrose", "lightcyan", "lavender", 2:20) [1:length(tparm)] bpx <- barplot( as.matrix(t( pea[,tparm])),ylab=ylabel, main=predtitle, beside=T, legend=F, col = tcols ) # ylim=c(0,ymax), legend( x="topright", colnames(pea[,tparm]), lwd=3, col=tcols) pea tparm <- c( 6,8,10) # ,15 = found ~= nearcount; 13,17 == align,nxfound ; 2,4, = far, inside tcols <- c("lightblue", "mistyrose", "lightcyan", "lavender", 2:20) [1:length(tparm)] pea[,tparm] / pea$Same_found pea[,tparm] <- pea[,tparm] / pea$Same_found tcols <- c("lightblue", "mistyrose", "lightcyan", "lavender", 2:20) [1:length(tparm)] bpx <- barplot( as.matrix(t( pea[,tparm])),ylab=ylabel, main=predtitle, beside=T, legend=F, col = tcols ) # ylim=c(0,ymax), legend( x="topright", colnames(pea[,tparm]), lwd=3, col=tcols) bpx <- barplot( as.matrix(t( pea[,tparm])),ylab=ylabel, main=predtitle, beside=T, legend=F, col = tcols ) # ylim=c(0,ymax), legend( x="topleft", colnames(pea[,tparm]), lwd=3, col=tcols) pe ggroup <- "GleanR" pelev <- grep("GLEANR|JGI",as.character(pe$ggroup),value=T) sppset <- c("dsec","dyak","dere","dpse","dwil","dgri","dappulx") spat <- paste(sppset,collapse="|") pefac <- factor(pe$ggroup, levels=pelev, ordered=T,exclude=NULL) pea <- pe[!is.na(pefac),c(-1,-2)] rown <- pe[!is.na(pefac),1] # species rownames(pea) <- rown pea <- pea[sppset,] pea predtitle <- paste("Pred. exons/species, predictor",ggroup) ylabel <- "exon count" pea$align <- pea$align/pea$cdslen pea$nxfound <- pea$nxfound/pea$nexon tparm <- c( 6,8,10) # ,15 = found ~= nearcount; 13,17 == align,nxfound ; 2,4, = far, inside pea[,tparm] <- pea[,tparm] / pea$Same_found tcols <- c("lightblue", "mistyrose", "lightcyan", "lavender", 2:20) [1:length(tparm)] bpx <- barplot( as.matrix(t( pea[,tparm])),ylab=ylabel, main=predtitle, beside=T, legend=F, col = tcols ) # ylim=c(0,ymax), legend( x="topleft", colnames(pea[,tparm]), lwd=3, col=tcols) ymax <- 0.05 # w/ above as relative Same, max is 0.03+ for Gnomon, 0.015 for GleanR tcols <- c("lightblue", "mistyrose", "lightcyan", "lavender", 2:20) [1:length(tparm)] bpx <- barplot( as.matrix(t( pea[,tparm])),ylab=ylabel, main=predtitle, ylim=c(0,ymax), beside=T, legend=F, col = tcols ) # legend( x="topleft", colnames(pea[,tparm]), lwd=3, col=tcols) ggroup <- "Gnomon" pelev <- grep("NCBI",as.character(pe$ggroup),value=T) pefac <- factor(pe$ggroup, levels=pelev, ordered=T,exclude=NULL) pea <- pe[!is.na(pefac),c(-1,-2)] rown <- pe[!is.na(pefac),1] # species rownames(pea) <- rown pea <- pea[sppset,] predtitle <- paste("Pred. exons/species, predictor",ggroup) ylabel <- "exon count" pea$align <- pea$align/pea$cdslen pea$nxfound <- pea$nxfound/pea$nexon tparm <- c( 6,8,10) # ,15 = found ~= nearcount; 13,17 == align,nxfound ; 2,4, = far, inside pea[,tparm] <- pea[,tparm] / pea$Same_found ymax <- 0.05 # w/ above as relative Same, max is 0.03+ for Gnomon, 0.015 for GleanR tcols <- c("lightblue", "mistyrose", "lightcyan", "lavender", 2:20) [1:length(tparm)] bpx <- barplot( as.matrix(t( pea[,tparm])),ylab=ylabel, main=predtitle, ylim=c(0,ymax), beside=T, legend=F, col = tcols ) # legend( x="topleft", colnames(pea[,tparm]), lwd=3, col=tcols) pea ggroup <- "GleanR" pelev <- grep("GLEANR|JGI",as.character(pe$ggroup),value=T) pelev pefac <- factor(pe$ggroup, levels=pelev, ordered=T,exclude=NULL) pefac pea <- pe[!is.na(pefac),c(-1,-2)] pea pea <- pe[!is.na(pefac),] pea rown <- pe[!is.na(pefac),1] # species rown rownames(pea) <- rown pea pea[sppset,] pe <- read.table("pexons.tandynear4.txt", header=T, strip.white=T) ggroup <- "Gnomon" pelev <- grep("NCBI",as.character(pe$ggroup),value=T) sppset <- c("dsec","dyak","dere","dana","dpse","dwil","dgri","dappulx") spat <- paste(sppset,collapse="|") pefac <- factor(pe$ggroup, levels=pelev, ordered=T,exclude=NULL) pea <- pe[!is.na(pefac),c(-1,-2)] rown <- pe[!is.na(pefac),1] # species rownames(pea) <- rown pea <- pea[sppset,] predtitle <- paste("Pred. exons/species, predictor",ggroup) ylabel <- "exon count" pea$align <- pea$align/pea$cdslen pea$nxfound <- pea$nxfound/pea$nexon tparm <- c( 6,8,10) # ,15 = found ~= nearcount; 13,17 == align,nxfound ; 2,4, = far, inside pea[,tparm] <- pea[,tparm] / pea$Same_found ymax <- 0.05 # w/ above as relative Same, max is 0.03+ for Gnomon, 0.015 for GleanR ymax <- 0.04 # w/ above as relative Same, max is 0.03+ for Gnomon, 0.015 for GleanR tcols <- c("lightblue", "mistyrose", "lightcyan", "lavender", 2:20) [1:length(tparm)] bpx <- barplot( as.matrix(t( pea[,tparm])),ylab=ylabel, main=predtitle, ylim=c(0,ymax), beside=T, legend=F, col = tcols ) # legend( x="topleft", colnames(pea[,tparm]), lwd=3, col=tcols) pe <- read.table("pexons.tandynear4.txt", header=T, strip.white=T) pe pe <- read.table("pexons.tandynear4.txt", header=T, strip.white=T) pe ggroup <- "Gnomon" pelev <- grep("NCBI",as.character(pe$ggroup),value=T) # should paste species, ggroup as one factor sppset <- c("dsec","dyak","dere","dana","dpse","dwil","dgri","dappulx") spat <- paste(sppset,collapse="|") pefac <- factor(pe$ggroup, levels=pelev, ordered=T,exclude=NULL) pea <- pe[!is.na(pefac),c(-1,-2)] rown <- pe[!is.na(pefac),1] # species rownames(pea) <- rown pea <- pea[sppset,] predtitle <- paste("Pred. exons/species, predictor",ggroup) ylabel <- "exon count" pea$align <- pea$align/pea$cdslen pea$nxfound <- pea$nxfound/pea$nexon tparm <- c( 6,8,10) # ,15 = found ~= nearcount; 13,17 == align,nxfound ; 2,4, = far, inside pea[,tparm] <- pea[,tparm] / pea$Same_found ymax <- 0.04 # w/ above as relative Same, max is 0.03+ for Gnomon, 0.015 for GleanR pea tcols <- c("lightblue", "mistyrose", "lightcyan", "lavender", 2:20) [1:length(tparm)] bpx <- barplot( as.matrix(t( pea[,tparm])),ylab=ylabel, main=predtitle, ylim=c(0,ymax), beside=T, legend=F, col = tcols ) # legend( x="topleft", colnames(pea[,tparm]), lwd=3, col=tcols) ggroup <- "GleanR" pelev <- grep("GLEANR|JGI",as.character(pe$ggroup),value=T) pea.gno <- pea pefac <- factor(pe$ggroup, levels=pelev, ordered=T,exclude=NULL) pea <- pe[!is.na(pefac),c(-1,-2)] rown <- pe[!is.na(pefac),1] # species rownames(pea) <- rown pea <- pea[sppset,] predtitle <- paste("Pred. exons/species, predictor",ggroup) ylabel <- "exon count" pea$align <- pea$align/pea$cdslen pea$nxfound <- pea$nxfound/pea$nexon tparm <- c( 6,8,10) # ,15 = found ~= nearcount; 13,17 == align,nxfound ; 2,4, = far, inside pea[,tparm] <- pea[,tparm] / pea$Same_found ymax <- 0.04 # w/ above as relative Same, max is 0.03+ for Gnomon, 0.015 for GleanR tcols <- c("lightblue", "mistyrose", "lightcyan", "lavender", 2:20) [1:length(tparm)] bpx <- barplot( as.matrix(t( pea[,tparm])),ylab=ylabel, main=predtitle, ylim=c(0,ymax), beside=T, legend=F, col = tcols ) # legend( x="topleft", colnames(pea[,tparm]), lwd=3, col=tcols) pea.glr <- pea pea.gno pea.glr pe <- read.table("pexons.tandynear4.txt", header=T, strip.white=T) ggroup <- "GleanR" pelev <- grep("GLEANR|JGI",as.character(pe$ggroup),value=T) ggroup <- "GleanR" pelev <- grep("GLEANR|JGI|FBtr",as.character(pe$ggroup),value=T) pelev sppset <- c("dmel","dsec","dyak","dere","dana","dpse","dwil","dgri","dappulx") spat <- paste(sppset,collapse="|") pefac <- factor(pe$ggroup, levels=pelev, ordered=T,exclude=NULL) pea <- pe[!is.na(pefac),c(-1,-2)] rown <- pe[!is.na(pefac),1] # species rownames(pea) <- rown pea <- pea[sppset,] predtitle <- paste("Pred. exons/species, predictor",ggroup) ylabel <- "exon count" pea tparm <- c( 6,8,10) # near_found ,15 = found ~= nearcount; 13,17 == align,nxfound ; 2,4, = far, inside tparm <- c( 5,7,9) # near ; lacks dyak odd spike > dyak tandems were found at higher rate than others? pea[,tparm] <- pea[,tparm] / pea$Same_found ymax <- 0.04 # w/ above as relative Same, max is 0.03+ for Gnomon, 0.015 for GleanR tcols <- c("lightblue", "mistyrose", "lightcyan", "lavender", 2:20) [1:length(tparm)] bpx <- barplot( as.matrix(t( pea[,tparm])),ylab=ylabel, main=predtitle, ylim=c(0,ymax), beside=T, legend=F, col = tcols ) # legend( x="topleft", colnames(pea[,tparm]), lwd=3, col=tcols) ymax <- 0.20 bpx <- barplot( as.matrix(t( pea[,tparm])),ylab=ylabel, main=predtitle, ylim=c(0,ymax), beside=T, legend=F, col = tcols ) # legend( x="topleft", colnames(pea[,tparm]), lwd=3, col=tcols) ymax <- 0.15 bpx <- barplot( as.matrix(t( pea[,tparm])),ylab=ylabel, main=predtitle, ylim=c(0,ymax), beside=T, legend=F, col = tcols ) # legend( x="topleft", colnames(pea[,tparm]), lwd=3, col=tcols) ymax <- 0.20 bpx <- barplot( as.matrix(t( pea[,tparm])),ylab=ylabel, main=predtitle, ylim=c(0,ymax), beside=T, legend=F, col = tcols ) # legend( x="topleft", colnames(pea[,tparm]), lwd=3, col=tcols) ggroup <- "Gnomon" pelev <- grep("NCBI",as.character(pe$ggroup),value=T) # should paste species, ggroup as one factor ymax <- 0.15 ggroup <- "GleanR" pelev <- grep("GLEANR|JGI|FBtr",as.character(pe$ggroup),value=T) bpx <- barplot( as.matrix(t( pea[,tparm])),ylab=ylabel, main=predtitle, ylim=c(0,ymax), beside=T, legend=F, col = tcols ) # legend( x="topleft", colnames(pea[,tparm]), lwd=3, col=tcols) ggroup <- "Gnomon" pelev <- grep("NCBI",as.character(pe$ggroup),value=T) # should paste species, ggroup as one factor sppset <- c("dmel","dsec","dyak","dere","dana","dpse","dwil","dgri","dappulx") spat <- paste(sppset,collapse="|") pefac <- factor(pe$ggroup, levels=pelev, ordered=T,exclude=NULL) pea <- pe[!is.na(pefac),c(-1,-2)] rown <- pe[!is.na(pefac),1] # species rownames(pea) <- rown pea <- pea[sppset,] predtitle <- paste("Pred. exons/species, predictor",ggroup) ylabel <- "exon count" pea$align <- pea$align/pea$cdslen pea$nxfound <- pea$nxfound/pea$nexon tparm <- c( 6,8,10) # near_found ,15 = found ~= nearcount; 13,17 == align,nxfound ; 2,4, = far, inside ymax <- 0.04 # w/ above as relative Same, max is 0.03+ for Gnomon, 0.015 for GleanR tparm <- c( 5,7,9) # near ; lacks dyak odd spike > dyak tandems were found at higher rate than others? ymax <- 0.15 # w/ above as relative Same, max is 0.03+ for Gnomon, 0.015 for GleanR pea[,tparm] <- pea[,tparm] / pea$Same_found tcols <- c("lightblue", "mistyrose", "lightcyan", "lavender", 2:20) [1:length(tparm)] bpx <- barplot( as.matrix(t( pea[,tparm])),ylab=ylabel, main=predtitle, ylim=c(0,ymax), beside=T, legend=F, col = tcols ) # legend( x="topleft", colnames(pea[,tparm]), lwd=3, col=tcols) ls()