Trouble with gcrma background correction
1
0
Entering edit mode
@sucheta-tripathy-987
Last seen 9.6 years ago
Dear Group, (Sorry for the repost- The earlier one could not get through) I am stuck with this problem for quite some time. I have been searching for an answer to this, but could not quite get a hold of it. Any help in this will be greatly appreciated. I am using R version 2.3.1 and bioconductor version 1.9. First I computed affinity using the following command: affinity.info <- compute.affinities("Soybean", verbose=TRUE) saveaffinity.info,file = "soybean.RData"); Then I load it using: library(gcrma) load("soybean.RData") source("gcrmaBG.R") when I run the script gcrmaBG.R inside another script, I get the following error: ERROR MESSAGES: =============== Adjusting for optical effect.Done. In first if and type is Adjusting for non-specific binding .type is fullmodel Error in model.frame(formula, rownames, variables, varnames, extras, extranames, : invalid variable type for 'affinities' Execution halted ========== gcrmaBG.R ========== gcrmaBG <- function(object, type=c("fullmodel","affinities","mm","constant"), k=6*fast+0.5*(1-fast),stretch=1.15*fast+1*(1-fast), correction=1,rho=0.7, optical.correct=TRUE,verbose=TRUE,fast=TRUE){ type <- match.arg(type) pmonly <- (type=="affinities"|type=="constant") needaff <- (type=="fullmodel"|type=="affinities") if(optical.correct){ object <- bg.adjust.optical(object,verbose=verbose) } pms_bg <- gcrma.engine(pms=pm(object), mms=mm(object), pm.affinities=pmaffinity.info), mm.affinities=mmaffinity.info), type=type,k=k, stretch=stretch, correction=correction,rho=rho, verbose=verbose,fast=fast) return(pms_bg) } bg.adjust.optical <- function(abatch,minimum=1,verbose=TRUE){ Index <- unlist(indexProbes(abatch,"both")) if(verbose) cat("Adjusting for optical effect") for(i in 1:length(abatch)){ if(verbose) cat(".") exprs(abatch)[Index,i] <- exprs(abatch)[Index,i] - min(exprs(abatch)[Index,i],na.rm=TRUE) + minimum } if(verbose) cat("Done.\n") abatch } # Defining function gcrma.engine gcrma.engine <- function(pms,mms,pm.affinities=NULL,mm.affinities=NULL, type=c("fullmodel","affinities","mm","constant"), k=6*fast+0.25*(1-fast), stretch=1.15*fast+1*(1-fast),correction=1,rho=0.7, verbose=TRUE,fast=TRUE){ type <- match.arg(type) if(!is.null(pm.affinities)){ index.affinities <- which(!is.na(pm.affinities)) pm.affinities <- pm.affinities[index.affinities] if(!is.null(mm.affinities)){ mm.affinities <- mm.affinities[index.affinities] } } if(type=="fullmodel" | type=="affinities"){ cat("In first if and type is \n") set.seed(1) Subset <- sample(1:length(pms[index.affinities,]),25000) y <- log2(pms)[index.affinities,][Subset] Subset <- (Subset-1)%%length(pms[index.affinities,])+1 x <- pm.affinities[Subset] fit1 <- lm(y~x) } cat("Adjusting for non-specific binding\n") for(i in 1:ncol(pms)){ if(verbose) cat(".") if(type=="fullmodel"){ cat("type is fullmodel\n") # ERROR HERE pms[,i] <- bg.adjust.fullmodel(pms[,i],mms[,i], pm.affinities,mm.affinities, index.affinities,k=k, rho=rho,fast=fast) cat("bg.adjust.fullmodel is done\n") pms[index.affinities,i] <- 2^(log2(pms[index.affinities,i])- fit1$coef[2]*pm.affinities+mean(fit1$coef[2] *pm.affinities)) } if(type=="affinities"){ cat("Type is affinities") pms[,i] <- bg.adjust.affinities(pms[,i],mms[,i], pm.affinities,mm.affinities, index.affinities, k=k, fast=fast) pms[index.affinities,i] <- 2^(log2(pms[index.affinities,i])- fit1$coef[2]*pm.affinities + mean(fit1$coef[2]*pm.affinities)) } if(type=="mm") pms[,i] <- bg.adjust.mm(pms[,i],correction*mms[,i],k=k,fast=f ast) cat("type is mm") # added by ST. if(type=="constant"){ cat("Type is constant") pms[,i] <- bg.adjust.constant(pms[,i],k=k,Q=correction*mean(pms[,i]<mms[,i ]),fast="fast)" }="" if(stretch!="1){" mu="" <-="" mean(log(pms[,i]))="" pms[,i]="" <-="" exp(mu="" +="" stretch*(log(pms[,i])-mu))="" }="" }="" if(verbose)="" cat("done.\n")="" return(pms)="" }="" many="" thanks="" sucheta="" --="" sucheta="" tripathy,="" ph.d.="" virginia="" bioinformatics="" institute="" phase-i="" washington="" street.="" virginia="" tech.="" blacksburg,va="" 24061-0447="" phone:(540)231-8138="" fax:="" (540)="" 231-2606="" web="" page:="" http:="" staff.vbi.vt.edu="" sutripa="" blog="" :="" http:="" genomics-array.blogspot.com="" <="" div="">
gcrma gcrma • 974 views
ADD COMMENT
0
Entering edit mode
@herve-pages-1542
Last seen 12 hours ago
Seattle, WA, United States
Hi Sucheta, Sucheta Tripathy wrote: > Dear Group, > > (Sorry for the repost- The earlier one could not get through) > I am stuck with this problem for quite some time. I have been searching > for an answer to this, but could not quite get a hold of it. Any help in > this will be greatly appreciated. > > I am using R version 2.3.1 and bioconductor version 1.9. We strongly discourage you of doing this. Bioconductor 1.9 has been designed and tested for R 2.4.z. It is not supported for R 2.3.z users so you are on your own... > > First I computed affinity using the following command: > > affinity.info <- compute.affinities("Soybean", verbose=TRUE) > saveaffinity.info,file = "soybean.RData"); > > Then I load it using: > > library(gcrma) > load("soybean.RData") > source("gcrmaBG.R") > > when I run the script gcrmaBG.R inside another script, I get the following > error: > > ERROR MESSAGES: > =============== > Adjusting for optical effect.Done. > In first if and type is > Adjusting for non-specific binding > .type is fullmodel > Error in model.frame(formula, rownames, variables, varnames, extras, > extranames, > : > invalid variable type for 'affinities' > Execution halted I suggest you upgrade to R 2.4.0 first and see if you can reproduce this error. Also, don't forget to provide the output of sessionInfo() so, among other things, people know with version of gcrma you are using. One last advice: the long script you provided below doesn't help much because: (1) some lines have been cut in the middle of a variable name if(type=="mm") pms[,i] <- bg.adjust.mm(pms[,i],correction*mms[,i],k=k,fast=f ast) so we can't just copy and paste it into a file and expect it to work without some extra editing work (2) it's too long Please try to reproduce the error in a few lines of code (no more than 10) and send only those 10 lines (with sessionInfo output). Thanks, H. > > ========== > gcrmaBG.R > ========== > > gcrmaBG <- function(object, > type=c("fullmodel","affinities","mm","constant"), > k=6*fast+0.5*(1-fast),stretch=1.15*fast+1*(1-fast), > correction=1,rho=0.7, > optical.correct=TRUE,verbose=TRUE,fast=TRUE){ > > > type <- match.arg(type) > > > pmonly <- (type=="affinities"|type=="constant") > needaff <- (type=="fullmodel"|type=="affinities") > > > if(optical.correct){ > object <- bg.adjust.optical(object,verbose=verbose) > } > > > pms_bg <- gcrma.engine(pms=pm(object), > mms=mm(object), > pm.affinities=pmaffinity.info), > mm.affinities=mmaffinity.info), > type=type,k=k, > stretch=stretch, > correction=correction,rho=rho, > verbose=verbose,fast=fast) > > return(pms_bg) > } > > > bg.adjust.optical <- function(abatch,minimum=1,verbose=TRUE){ > Index <- unlist(indexProbes(abatch,"both")) > > > if(verbose) cat("Adjusting for optical effect") > > for(i in 1:length(abatch)){ > if(verbose) cat(".") > exprs(abatch)[Index,i] <- exprs(abatch)[Index,i] - > min(exprs(abatch)[Index,i],na.rm=TRUE) + minimum > } > > if(verbose) cat("Done.\n") > > abatch > > } > > > # Defining function gcrma.engine > > gcrma.engine <- function(pms,mms,pm.affinities=NULL,mm.affinities=NULL, > type=c("fullmodel","affinities","mm","constant"), > k=6*fast+0.25*(1-fast), > stretch=1.15*fast+1*(1-fast),correction=1,rho=0.7, > verbose=TRUE,fast=TRUE){ > type <- match.arg(type) > > if(!is.null(pm.affinities)){ > index.affinities <- which(!is.na(pm.affinities)) > pm.affinities <- pm.affinities[index.affinities] > > if(!is.null(mm.affinities)){ > mm.affinities <- mm.affinities[index.affinities] > } > > } > > > if(type=="fullmodel" | type=="affinities"){ > > cat("In first if and type is \n") > > set.seed(1) > Subset <- sample(1:length(pms[index.affinities,]),25000) > y <- log2(pms)[index.affinities,][Subset] > Subset <- (Subset-1)%%length(pms[index.affinities,])+1 > x <- pm.affinities[Subset] > fit1 <- lm(y~x) > } > > > cat("Adjusting for non-specific binding\n") > for(i in 1:ncol(pms)){ > if(verbose) cat(".") > if(type=="fullmodel"){ > > cat("type is fullmodel\n") # ERROR HERE > > pms[,i] <- bg.adjust.fullmodel(pms[,i],mms[,i], > pm.affinities,mm.affinities, > index.affinities,k=k, > rho=rho,fast=fast) > cat("bg.adjust.fullmodel is done\n") > > pms[index.affinities,i] <- 2^(log2(pms[index.affinities,i])- > fit1$coef[2]*pm.affinities+mean(fit1$coef[2] > *pm.affinities)) > } > > if(type=="affinities"){ > cat("Type is affinities") > pms[,i] <- bg.adjust.affinities(pms[,i],mms[,i], > pm.affinities,mm.affinities, > index.affinities, k=k, > fast=fast) > pms[index.affinities,i] <- 2^(log2(pms[index.affinities,i])- > fit1$coef[2]*pm.affinities + > mean(fit1$coef[2]*pm.affinities)) > } > > if(type=="mm") pms[,i] <- > bg.adjust.mm(pms[,i],correction*mms[,i],k=k,fast=f > ast) > > cat("type is mm") # added by ST. > > if(type=="constant"){ > cat("Type is constant") > pms[,i] <- > bg.adjust.constant(pms[,i],k=k,Q=correction*mean(pms[,i]<mms[,i> ]),fast=fast) > } > if(stretch!=1){ > mu <- mean(log(pms[,i])) > pms[,i] <- exp(mu + stretch*(log(pms[,i])-mu)) > } > } > > if(verbose) cat("Done.\n") > > return(pms) > } > > Many thanks > > Sucheta >
ADD COMMENT
0
Entering edit mode
Hi Herve, Group, Thanks for your response. As suggested by you, I have installed R version 2.4.0 with bioconductor 1.9. I recreated the cdf environment and computed affinity data. I still get the same error: ============================ Error in model.frame(formula, rownames, variables, varnames, extras, extranames, : invalid type (NULL) for variable 'affinities' Execution halted Following is my sessionInfo(): ============================== R version 2.4.0 (2006-10-03) i686-pc-linux-gnu locale: LC_CTYPE=en_US;LC_NUMERIC=C;LC_TIME=en_US;LC_COLLATE=C;LC_MONETARY=en_ US;LC_MESS AGES=en_US;LC_PAPER=en_US;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEA SUREMENT=e n_US;LC_IDENTIFICATION=C attached base packages: [1] "methods" "stats" "graphics" "grDevices" "utils" "datasets" [7] "base" And the error comes from this code fragment. Possibly I am passing wrong arguement for type fullmodel. Code sample: ============ for(i in 1:ncol(pms)){ if(verbose) cat(".") if(type=="fullmodel"){ cat("type is fullmodel\n") # ERROR HERE pms[,i] <- bg.adjust.fullmodel(pms[,i],mms[,i], pm.affinities,mm.affinities, index.affinities,k=k, rho=rho,fast=fast) cat("bg.adjust.fullmodel is done\n") pms[index.affinities,i] <- 2^(log2(pms[index.affinities,i])- fit1$coef[2]*pm.affinities+mean(fit1$coef[2] *pm.affinities)) } ==== Any help in solving this will be greatly appreciated. many thanks Sucheta On Fri, November 17, 2006 1:21 pm, Herve Pages wrote: > Hi Sucheta, > > > Sucheta Tripathy wrote: > >> Dear Group, >> >> >> (Sorry for the repost- The earlier one could not get through) >> I am stuck with this problem for quite some time. I have been searching >> for an answer to this, but could not quite get a hold of it. Any help in >> this will be greatly appreciated. >> >> I am using R version 2.3.1 and bioconductor version 1.9. >> > > We strongly discourage you of doing this. Bioconductor 1.9 has been > designed and tested for R 2.4.z. It is not supported for R 2.3.z users so > you are on your own... > >> >> First I computed affinity using the following command: >> >> >> affinity.info <- compute.affinities("Soybean", verbose=TRUE) >> saveaffinity.info,file = "soybean.RData"); >> >> Then I load it using: >> >> >> library(gcrma) load("soybean.RData") source("gcrmaBG.R") >> >> when I run the script gcrmaBG.R inside another script, I get the >> following error: >> >> >> ERROR MESSAGES: >> =============== >> Adjusting for optical effect.Done. >> In first if and type is >> Adjusting for non-specific binding >> .type is fullmodel >> Error in model.frame(formula, rownames, variables, varnames, extras, >> extranames, : >> invalid variable type for 'affinities' Execution halted >> > > > I suggest you upgrade to R 2.4.0 first and see if you can reproduce this > error. Also, don't forget to provide the output of sessionInfo() so, among > other things, people know with version of gcrma you are using. > > One last advice: the long script you provided below doesn't help much > because: > > > (1) some lines have been cut in the middle of a variable name > if(type=="mm") pms[,i] <- > bg.adjust.mm(pms[,i],correction*mms[,i],k=k,fast=f ast) so we can't just > copy and paste it into a file and expect it to work without some extra > editing work > > (2) it's too long > > > Please try to reproduce the error in a few lines of code (no more than > 10) > and send only those 10 lines (with sessionInfo output). > > Thanks, > > > H. > > > >> -- Sucheta Tripathy, Ph.D. Virginia Bioinformatics Institute Phase-I Washington street. Virginia Tech. Blacksburg,VA 24061-0447 phone:(540)231-8138 Fax: (540) 231-2606 web page: http://staff.vbi.vt.edu/sutripa blog : http://genomics-array.blogspot.com/
ADD REPLY

Login before adding your answer.

Traffic: 975 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6