r-gregmisc-users Mailing List for R gregmisc package (Page 38)
Brought to you by:
warnes
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
(12) |
Apr
(5) |
May
(3) |
Jun
(5) |
Jul
(2) |
Aug
(5) |
Sep
(7) |
Oct
(15) |
Nov
(34) |
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(3) |
Feb
(16) |
Mar
(28) |
Apr
(5) |
May
|
Jun
(5) |
Jul
(9) |
Aug
(50) |
Sep
(29) |
Oct
(9) |
Nov
(25) |
Dec
(7) |
2008 |
Jan
(6) |
Feb
(4) |
Mar
(5) |
Apr
(8) |
May
(26) |
Jun
(11) |
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(9) |
2009 |
Jan
|
Feb
(1) |
Mar
|
Apr
(2) |
May
(26) |
Jun
|
Jul
(10) |
Aug
(6) |
Sep
|
Oct
(7) |
Nov
(3) |
Dec
(2) |
2010 |
Jan
(45) |
Feb
(11) |
Mar
|
Apr
(1) |
May
(8) |
Jun
(7) |
Jul
(3) |
Aug
(1) |
Sep
|
Oct
(1) |
Nov
(9) |
Dec
(1) |
2011 |
Jan
(2) |
Feb
|
Mar
|
Apr
(3) |
May
(1) |
Jun
|
Jul
|
Aug
(14) |
Sep
(29) |
Oct
(3) |
Nov
|
Dec
(3) |
2012 |
Jan
|
Feb
|
Mar
|
Apr
(7) |
May
(6) |
Jun
(59) |
Jul
|
Aug
(8) |
Sep
(21) |
Oct
|
Nov
|
Dec
|
2013 |
Jan
(1) |
Feb
|
Mar
(10) |
Apr
|
May
(18) |
Jun
(25) |
Jul
(18) |
Aug
(1) |
Sep
(6) |
Oct
(28) |
Nov
(4) |
Dec
(13) |
2014 |
Jan
(7) |
Feb
(5) |
Mar
(4) |
Apr
(36) |
May
(3) |
Jun
(7) |
Jul
(46) |
Aug
(14) |
Sep
(12) |
Oct
(2) |
Nov
|
Dec
(12) |
2015 |
Jan
(4) |
Feb
|
Mar
|
Apr
(80) |
May
(36) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <wa...@us...> - 2007-03-01 22:42:17
|
Revision: 1060 http://svn.sourceforge.net/r-gregmisc/?rev=1060&view=rev Author: warnes Date: 2007-03-01 14:42:15 -0800 (Thu, 01 Mar 2007) Log Message: ----------- Correct spelling error Modified Paths: -------------- trunk/PathwayModeling/thesispaper/discussion.Snw Modified: trunk/PathwayModeling/thesispaper/discussion.Snw =================================================================== --- trunk/PathwayModeling/thesispaper/discussion.Snw 2007-03-01 22:38:28 UTC (rev 1059) +++ trunk/PathwayModeling/thesispaper/discussion.Snw 2007-03-01 22:42:15 UTC (rev 1060) @@ -4,42 +4,43 @@ $Id$ \end{verbatim} -We are interested in assessing the usefulness of Markov chain Monte Carlo -(MCMC) methods for the fitting of models of metabolic pathways. Fitting -metabolic pathway models can be difficult because pathways are described by sets -of reaction rate equations with overlapping sets of parameters. We have -found that the MCMC algorithms handle this situation well, and produce -reasonable joint probability densities for the model parameters. -This output can be used for the estimation of confidence intervals -for the parameters and the detection of correlations and multimodality. -Thus MCMC compares favorably with maximum likelyhood methods that -produce point estimates of the parameters and nonlinear regression -methods that find approximations of the parameters and their variances. +We are interested in assessing the usefulness of Markov chain Monte +Carlo (MCMC) methods for the fitting of models of metabolic +pathways. Fitting metabolic pathway models can be difficult because +pathways are described by sets of reaction rate equations with +overlapping sets of parameters. We have found that the MCMC algorithms +handle this situation well, and produce reasonable joint probability +densities for the model parameters. This output can be used for the +estimation of confidence intervals for the parameters and the +detection of correlations and multimodality. Thus MCMC compares +favorably with maximum likelihood methods that produce point estimates +of the parameters and nonlinear regression methods that find +approximations of the parameters and their variances. -MCMC methods and Bayesian statistics are -particularly useful for modeling networks of biological reactions. These -networks typically are modeled by large numbers of parameters and -frequentist methods require at least as many observations as there are -parameters to fit a model. In contrast, Bayesian methods incorporate our -prior knowledge of the system and use the experimental data to refine -the estimates (Figure~\ref{converged}). Thus the model fitting procedure -described here lends itself to iterative experimentation where the -experimental results, even if they consit of a single datum, can be -used to update the prior for the next experiment. +MCMC methods and Bayesian statistics are particularly useful for +modeling networks of biological reactions. These networks typically +are modeled by large numbers of parameters and frequentist methods +require at least as many observations as there are parameters to fit a +model. In contrast, Bayesian methods incorporate our prior knowledge +of the system and use the experimental data to refine the estimates +(Figure~\ref{converged}). Thus the model fitting procedure described +here lends itself to iterative experimentation where the experimental +results, even if they consit of a single datum, can be used to update +the prior for the next experiment. -The models used here have the form of the Hill function, -$\frac{x^n}{\theta^n+x^n}$, with an exponent of 1. This form was chosen -because the functions exhibit two of the characteristics of -enzyme-catalyzed reactions: linearity at low concentrations of substrate -and saturability. This, of course, is also the form of the -Michaelis-Menten equation. These functions have the reactant -concentrations as the independent variables since they are quantities that -are relatively easy to measure. A drawback with these models is that they -describe irreversible reactions whereas most enzymatic reactions are -reversible. We have tried using a model of reversible reactions, the -Haldane equation, but it does not fit the data from a perturbation -equation very well. It can be used with MCMC simulation for multiple -steady states, a situation we will continue to examine. +The models used here have the form of the Hill function, +$\frac{x^n}{\theta^n+x^n}$, with an exponent of 1. This form was +chosen because the functions exhibit two of the characteristics of +enzyme-catalyzed reactions: linearity at low concentrations of +substrate and saturability. This, of course, is also the form of the +Michaelis-Menten equation. These functions have the reactant +concentrations as the independent variables since they are quantities +that are relatively easy to measure. A drawback with these models is +that they describe irreversible reactions whereas most enzymatic +reactions are reversible. We have tried using a model of reversible +reactions, the Haldane equation, but it does not fit the data from a +perturbation equation very well. It can be used with MCMC simulation +for multiple steady states, a situation we will continue to examine. Three algorithms from the Hydra library were used. Two of the algorithms, the component-wise Metropolis and the all-components Metropolis This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-03-01 22:38:41
|
Revision: 1059 http://svn.sourceforge.net/r-gregmisc/?rev=1059&view=rev Author: warnes Date: 2007-03-01 14:38:28 -0800 (Thu, 01 Mar 2007) Log Message: ----------- Changes in response to review, part 1 Modified Paths: -------------- trunk/PathwayModeling/thesispaper/.Rhistory trunk/PathwayModeling/thesispaper/R/plotConverged_nocolor.R trunk/PathwayModeling/thesispaper/R/plotDensity_nocolor.R trunk/PathwayModeling/thesispaper/figure5.Snw trunk/PathwayModeling/thesispaper/introduction.Snw trunk/PathwayModeling/thesispaper/methods.Snw trunk/PathwayModeling/thesispaper/paper.Snw trunk/PathwayModeling/thesispaper/paper.pdf trunk/PathwayModeling/thesispaper/results.Snw Added Paths: ----------- trunk/PathwayModeling/thesispaper/priorPlot.Snw Removed Paths: ------------- trunk/PathwayModeling/thesispaper/.RData Deleted: trunk/PathwayModeling/thesispaper/.RData =================================================================== --- trunk/PathwayModeling/thesispaper/.RData 2007-02-16 23:15:42 UTC (rev 1058) +++ trunk/PathwayModeling/thesispaper/.RData 2007-03-01 22:38:28 UTC (rev 1059) @@ -1,8 +0,0 @@ -RDX2 -X - |
From: <wa...@us...> - 2007-02-16 23:15:43
|
Revision: 1058 http://svn.sourceforge.net/r-gregmisc/?rev=1058&view=rev Author: warnes Date: 2007-02-16 15:15:42 -0800 (Fri, 16 Feb 2007) Log Message: ----------- Move Examples.R to tests/ and modify it to be useful. Added Paths: ----------- trunk/RMCMC/tests/ trunk/RMCMC/tests/Examples.R Removed Paths: ------------- trunk/RMCMC/R/Examples.R Deleted: trunk/RMCMC/R/Examples.R =================================================================== --- trunk/RMCMC/R/Examples.R 2007-02-16 23:11:53 UTC (rev 1057) +++ trunk/RMCMC/R/Examples.R 2007-02-16 23:15:42 UTC (rev 1058) @@ -1,190 +0,0 @@ - -####### -# Sample abstract Model -####### - -Example.Model <- model( - Y = 1/Z, #Z = 1/Y fixed relationships must be expressed with - # parameters on the LHS and - # observed values on the RHS - Y ~ N(X%*%Beta,sigma.2), - Beta ~ N(0,Beta.var.2), - sigma.2 ~ InvGamma( V, 1) - ) - # returns an object of class 'model' - -X.data <- rnorm(10) -Y.data <- rnorm(X.data*2) # hidden variable -Z.data <- 1/Y.data - -Example.Data <- list( - Beta.var.2 = 90, - V = 30, - X = X.data, - Z = Z.data, - ) - -###### -# Sample concrete Model -###### - -Example.Model <- model( - Y = 1/Z, #Z = 1/Y, fixed relationships must be expressed with - # parameters on the LHS and - # observed values on the RHS - Y ~ N(X%*%Beta,sigma.2), - Beta ~ N(0,Beta.var.2), - sigma.2 ~ InvGamma( V, 1), - - data = list( - Beta.var.2 = 90, - V = 30, - X = X.data, - Z = Z.data, - ) - ) - -######### -# Example Concrete Model with Blocking -######### - -# Block on the beta -Example.Model <- model( - Y = 1/Z, #Z = 1/Y, fixed relationships must be expressed with - # parameters on the LHS and - # observed values on the RHS - Y ~ N(X%*%Beta,sigma.2) - Beta ~ MvN(rep(0,30),diag(Beta.var.2,30)) - sigma.2 ~ invGamma( V, 1), - - data = list( - Beta.var.2 = 90 - V = 30 - X = X.data - Z = Z.data - ) - ) - - -# Block on several parameters that are not part of the same distribution -Example.Model <- model( - Y = 1/Z, #Z = 1/Y, fixed relationships must be expressed with - # parameters on the LHS and - # observed values on the RHS - Y ~ MvN(X%*%Beta,diag(sigma.2,30)) - Beta[ 1:10] ~ NvN(0,diag(Beta.var.2,10)) - Beta[11:30] ~ MvN(0,diag(Beta.var.2,20)) - sigma.2 ~ InvGamma( V, 1), - - data = list( - Beta.var.2 = 90 - V = 30 - X = X.data - Z = Z.data - ) - ) - -# Block on sigma & beta -Example.Model <- model( - Y = 1/Z, #Z = 1/Y, fixed relationships must be expressed with - # parameters on the LHS and - # observed values on the RHS - Y ~ N(X%*%Beta,sigma.2) - Beta ~ MvN(rep(0,30),diag(Beta.var.2,30)) - sigma.2 ~ invGamma( V, 1) - - <all other variables> - - data = list( - Beta.var.2 = 90 - V = 30 - X = X.data - Z = Z.data - ) - ) - - -######### -# Example proposal -######### - -Proposal.Model <- model( - Beta <- N(Beta,30), - sigma.2 <- InvGamma( 25, 1) -) - -# --> proposalGenerator <- function(Beta,sigma^2) -# { -# Beta.new <- rnorm(Beta,30) -# sigma.2.mew <- rInvGamma( 25, 1) -# return( list(Beta=Beta.new, -# sigma.2=sigma.2.new) -# ) -# } -# -# --> proposalDensity <- function(Beta,sigma.2) -# { -# Beta.logLik <- log(dnorm(Beta,30)) -# sigma.2.logLik <- dInvGamma( sigma.2, 25, 1) -# return( sum(Beta.loglik, sigma.2.loglik) -# } -# - -# For the last example of blocking -# --> proposalGenerator <- list( -# f1 <- function(Beta, sigma.2, <all other parameters>) -# { -# Beta.new <- rnorm(Beta,30) -# sigma.2.mew <- rInvGamma( 25, 1) -# return( list(Beta=Beta.new, -# sigma.2=sigma.2.new) ) -# } -# f2 <- function(Beta, sigma.2, <all other parameters>) -# { -# <...> -# } -# ) - -######## -# Example Sampler -######## - - -# Convert model code + data into R functions -makeDensity.model <- function(model, data) -{ - # returns a function for <logDensity> = fun(current=<current state>) - # <OR> a set of functions, one for each model parameter - # parse model into 'tree' - # manipulate tree - # convert tree to output - density.function <- function(current.state) {} - density.function - - -} - -# For Gibb Sampler - -MakeGibbsProposal.model <- function(model) -{ - # returns a function for <new state> = fun(current=<current state>) -} - -# For Metropolis Proposal - - -# Covert proposal model to functions - -MakeProposalGenrator <- function(model, data) -{ - # returns a function for <new state> = fun(current=<current state>) -} - -MakeProposalDensity <- function(model, data) -{ - # returns a function for <logDensity> = fun(current=<current state>, proposed=<proposaed state>) -} - - - Added: trunk/RMCMC/tests/Examples.R =================================================================== --- trunk/RMCMC/tests/Examples.R (rev 0) +++ trunk/RMCMC/tests/Examples.R 2007-02-16 23:15:42 UTC (rev 1058) @@ -0,0 +1,198 @@ +library(RMCMC) + +####### +# Sample abstract Model +####### + +Example.Model <- model( + Y = 1/Z, #Z = 1/Y fixed relationships must be expressed with + # parameters on the LHS and + # observed values on the RHS + Y ~ N(X%*%Beta,sigma.2), + Beta ~ N(0,Beta.var.2), + sigma.2 ~ InvGamma( V, 1) + ) + # returns an object of class 'model' + +X.data <- rnorm(10) +Y.data <- rnorm(X.data*2) # hidden variable +Z.data <- 1/Y.data + +Example.Data <- list( + Beta.var.2 = 90, + V = 30, + X = X.data, + Z = Z.data, + ) + +###### +# Sample concrete Model +###### + +Example.Model <- model( + Y = 1/Z, #Z = 1/Y, fixed relationships must be expressed with + # parameters on the LHS and + # observed values on the RHS + Y ~ N(X%*%Beta,sigma.2), + Beta ~ N(0,Beta.var.2), + sigma.2 ~ InvGamma( V, 1), + + data = list( + Beta.var.2 = 90, + V = 30, + X = X.data, + Z = Z.data, + ) + ) + +######### +# Example Concrete Model with Blocking +######### + +# Block on the beta +Example.Model <- model( + Y = 1/Z, #Z = 1/Y, fixed relationships must be expressed with + # parameters on the LHS and + # observed values on the RHS + Y ~ N(X%*%Beta,sigma.2) + Beta ~ MvN(rep(0,30),diag(Beta.var.2,30)) + sigma.2 ~ invGamma( V, 1), + + data = list( + Beta.var.2 = 90 + V = 30 + X = X.data + Z = Z.data + ) + ) + + +# Block on several parameters that are not part of the same distribution +Example.Model <- model( + Y = 1/Z, #Z = 1/Y, fixed relationships must be expressed with + # parameters on the LHS and + # observed values on the RHS + Y ~ MvN(X%*%Beta,diag(sigma.2,30)) + Beta[ 1:10] ~ NvN(0,diag(Beta.var.2,10)) + Beta[11:30] ~ MvN(0,diag(Beta.var.2,20)) + sigma.2 ~ InvGamma( V, 1), + + data = list( + Beta.var.2 = 90 + V = 30 + X = X.data + Z = Z.data + ) + ) + +# Block on sigma & beta +Example.Model <- model( + Y = 1/Z, #Z = 1/Y, fixed relationships must be expressed with + # parameters on the LHS and + # observed values on the RHS + Y ~ N(X%*%Beta,sigma.2) + Beta ~ MvN(rep(0,30),diag(Beta.var.2,30)) + sigma.2 ~ invGamma( V, 1) + + <all other variables> + + data = list( + Beta.var.2 = 90 + V = 30 + X = X.data + Z = Z.data + ) + ) + + +######### +# Example proposal +######### + +Proposal.Model <- model( + Beta <- N(Beta,30), + sigma.2 <- InvGamma( 25, 1) + ) + +# --> proposalGenerator <- function(Beta,sigma^2) +# { +# Beta.new <- rnorm(Beta,30) +# sigma.2.mew <- rInvGamma( 25, 1) +# return( list(Beta=Beta.new, +# sigma.2=sigma.2.new) +# ) +# } +# +# --> proposalDensity <- function(Beta,sigma.2) +# { +# Beta.logLik <- log(dnorm(Beta,30)) +# sigma.2.logLik <- dInvGamma( sigma.2, 25, 1) +# return( sum(Beta.loglik, sigma.2.loglik) +# } +# + +# For the last example of blocking +# --> proposalGenerator <- list( +# f1 <- function(Beta, sigma.2, <all other parameters>) +# { +# Beta.new <- rnorm(Beta,30) +# sigma.2.mew <- rInvGamma( 25, 1) +# return( list(Beta=Beta.new, +# sigma.2=sigma.2.new) ) +# } +# f2 <- function(Beta, sigma.2, <all other parameters>) +# { +# <...> +# } +# ) + +######## +# Example Sampler +######## + + +## Convert model code + data into R functions +#makeDensity.model <- function(model, data) +#{ +# # returns a function for <logDensity> = fun(current=<current state>) +# # <OR> a set of functions, one for each model parameter +# # parse model into 'tree' +# # manipulate tree +# # convert tree to output +# density.function <- function(current.state) {} +# density.function + + +#} + +## For Gibb Sampler + +#MakeGibbsProposal.model <- function(model) +#{ +# # returns a function for <new state> = fun(current=<current state>) +#} + +## For Metropolis Proposal + + +## Covert proposal model to functions + +#MakeProposalGenrator <- function(model, data) +#{ +# # returns a function for <new state> = fun(current=<current state>) +#} + +#MakeProposalDensity <- function(model, data) +#{ +# # returns a function for <logDensity> = fun(current=<current state>, proposed=<proposaed state>) +#} + + + +library(MCMCpack) +tmp <- make.density(Example.Model, Example.Data) +tmp(Beta=rep(1,10), sigma.2=1) + + +b.bb.model <- model( + ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-02-16 23:11:55
|
Revision: 1057 http://svn.sourceforge.net/r-gregmisc/?rev=1057&view=rev Author: warnes Date: 2007-02-16 15:11:53 -0800 (Fri, 16 Feb 2007) Log Message: ----------- Add initial code for mh() to generate a Metropolis-Hastings sampler Added Paths: ----------- trunk/RMCMC/R/mh.R Added: trunk/RMCMC/R/mh.R =================================================================== --- trunk/RMCMC/R/mh.R (rev 0) +++ trunk/RMCMC/R/mh.R 2007-02-16 23:11:53 UTC (rev 1057) @@ -0,0 +1,96 @@ +## return a function that generates a Metropolis-Hastings MCMC sampler +## using the provided posterior and proposal. Extra arguments will be +## appended to the call to the proposal. + +mh <- function( posterior, qgenerator, qdensity, x0, ..., log=FALSE) + { + npar <- unlist(length(x0)) + # ensure everything works, so we show errors early on + cat("Testing that the posterior density function works properly on x0...") + posterior(unlist(x0)) + cat("Success.\n") + + cat("Testing that the proposal generator function works properly on x0...") + qgenerator(unlist(x0)) + cat("Success.\n") + + cat("Testing that the proposal generator function works properly on x0...") + qdensity(unlist(x0), unlist(x0)) + cat("Success.\n") + + constructor <- match.call() + + fun <- function(x0, niter) + { + ## test parameters + if(niter <1) niter <- 0 + + ## step 0: setup + X <- matrix( NA, nrow=niter+1, ncol=npar ) # sampler state + X[1,] <- unlist(x0) # initial state + # note that X is 1 element longer than the number of iterations + + Y <- matrix( NA, nrow=niter+1, ncol=npar ) # proposed state + + p.X <- numeric(length=npar) # p(X): posterior density at X + p.Y <- numeric(length=npar) # p(Y): posterior density at Y + + q.Y.X <- numeric(length=npar) # q(X,Y):proposal density from X to Y + q.X.Y <- numeric(length=npar) # q(Y,X):proposal density from Y to X + + alpha <- numeric(length=npar) # alpha(X,Y): trans. prob form X to Y + + + for(t in 1:niter+1) + { + ## step 1: generate Y + Y[t] <- proposal(X[t], ...) + + ## step 2: calculate transition probability + if(log) + { + p.X[t] <- posterior(X[t], log=TRUE) + p.Y[t] <- posterior(Y[t], log=TRUE) + + q.X.Y[y] <- qdensity( X[t], Y[t], log=TRUE) + q.Y.X[y] <- qdensity( Y[t], X[t], log=TRUE) + + alpha <- max(1, exp(p.X[t] - p.Y[t] + q.Y.X[t] - q.X.Y[t])) + } + else + { + p.X[t] <- posterior(X[t]) + p.Y[t] <- posterior(Y[t]) + + q.X.Y[t] <- qdensity( X[t], Y[t]) + q.Y.X[t] <- qdensity( Y[t], X[t]) + + alpha[t] <- max(1, p.X[t] / p.Y[t] * q.Y.X[t] / q.X.Y[t]) + } + + ## step 3: flip a coin to decide whether X_t or Y is the next state + u <- runif() + if( u < alpha[t] ) + X[t+1] <- Y + else + X[t+1] <- X[t] + } + + retval <- list( + niter=niter, + X = X, + Y = Y, + p.X = p.X, + p.Y = p.Y, + q.Y.X = q.Y.X, + q.X.Y = q.X.Y, + alpha = alpha, + call = match.call(), + constructor=constructor, + ) + + + } + + + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-02-16 23:10:40
|
Revision: 1056 http://svn.sourceforge.net/r-gregmisc/?rev=1056&view=rev Author: warnes Date: 2007-02-16 15:10:38 -0800 (Fri, 16 Feb 2007) Log Message: ----------- Better text description Modified Paths: -------------- trunk/RMCMC/DESCRIPTION Modified: trunk/RMCMC/DESCRIPTION =================================================================== --- trunk/RMCMC/DESCRIPTION 2007-02-15 18:40:06 UTC (rev 1055) +++ trunk/RMCMC/DESCRIPTION 2007-02-16 23:10:38 UTC (rev 1056) @@ -1,7 +1,15 @@ Package: RMCMC -Title: MCMC within R +Title: General-purpose Markov Chain Monte Carlo for R Version: 0.1.0 -Author: Gregory R. Warnes <wa...@bs...> -Description: Tools to perform MCMC within R -Maintainer: Gregory R. Warnes <wa...@bs...> -License: LGPL +Author: Gregory R. Warnes <wa...@bs...> +Description: + This package allows users to easily specify and fit + Bayesian models via Markov Chain Monte Carlo (MCMC). Models + may be specified using standard Bayesian model + "twiddle" notation. Functions are provided to convert these + models into density functions and random generators, and to + use these estimate the posterior density using a variety of + MCMC algorithms, including the general Metropolis-Hastings and + Metropolis algorithms. +Maintainer: Gregory R. Warnes <wa...@bs...> +License: GPL This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-02-15 18:41:16
|
Revision: 1055 http://svn.sourceforge.net/r-gregmisc/?rev=1055&view=rev Author: warnes Date: 2007-02-15 10:40:06 -0800 (Thu, 15 Feb 2007) Log Message: ----------- Improve test code Modified Paths: -------------- trunk/fork/tests/test_many_fork.R Modified: trunk/fork/tests/test_many_fork.R =================================================================== --- trunk/fork/tests/test_many_fork.R 2007-02-15 18:25:30 UTC (rev 1054) +++ trunk/fork/tests/test_many_fork.R 2007-02-15 18:40:06 UTC (rev 1055) @@ -6,15 +6,22 @@ # start signal handler .C("R_install_sigcld_handler") +cat("Hi from the parent process\n"); + for(i in 1:100) { pid = fork(slave=NULL) - if(pid==0) { - cat("Hi from the child process\n"); exit() - } else { - cat("Hi from the parent process\n"); - } + if(pid==0) + { + cat("Hi from child process",getpid(),".\n"); + Sys.sleep(10); + cat("Bye from child process",getpid(),".\n"); + exit() + } } +Sys.sleep(300) +cat("Bye from the parent process",pid,".\n"); + # remove signal handler .C("R_restore_sigcld_handler") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-02-15 18:25:35
|
Revision: 1054 http://svn.sourceforge.net/r-gregmisc/?rev=1054&view=rev Author: warnes Date: 2007-02-15 10:25:30 -0800 (Thu, 15 Feb 2007) Log Message: ----------- Fix typo. Modified Paths: -------------- trunk/fork/src/sigchld_handler.c Modified: trunk/fork/src/sigchld_handler.c =================================================================== --- trunk/fork/src/sigchld_handler.c 2007-02-14 22:48:47 UTC (rev 1053) +++ trunk/fork/src/sigchld_handler.c 2007-02-15 18:25:30 UTC (rev 1054) @@ -17,7 +17,7 @@ struct sigaction sa ; // our sigcld signal handler struct sigaction osa; // original (R) signal hander -void sigchld_hander(int dummy) +void sigchld_handler(int dummy) { int st; while (wait3(&st, WNOHANG, NULL) > 0); @@ -31,8 +31,7 @@ if(installed==0) { Rprintf ("Installing SIGCHLD signal handler..."); - //sa.sa_handler = sigchld_handler; - sa.sa_handler = waiter; + sa.sa_handler = sigchld_handler; //sigfillset (&sa.sa_mask); //sa.sa_flags = SA_RESTART; ret = sigaction (SIGCHLD, &sa, &osa); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-02-14 22:49:26
|
Revision: 1053 http://svn.sourceforge.net/r-gregmisc/?rev=1053&view=rev Author: warnes Date: 2007-02-14 14:48:47 -0800 (Wed, 14 Feb 2007) Log Message: ----------- Add code to install SIGCHLD handler to avoid forked children from becoming zombies Added Paths: ----------- trunk/fork/src/sigchld_handler.c trunk/fork/tests/ trunk/fork/tests/test_many_fork.R Added: trunk/fork/src/sigchld_handler.c =================================================================== --- trunk/fork/src/sigchld_handler.c (rev 0) +++ trunk/fork/src/sigchld_handler.c 2007-02-14 22:48:47 UTC (rev 1053) @@ -0,0 +1,73 @@ +#include <R.h> +#include <Rdefines.h> + +/* + Code taken from a posting to the Gimp-developer mailing list by + Raphael Quinet quinet at gamers.org accessible at: + http://lists.xcf.berkeley.edu/lists/gimp-developer/2000-November/013572.html +*/ + +#include <signal.h> +#include <sys/types.h> +#include <sys/wait.h> +#include <unistd.h> + +int installed=0; // Has our sigcld signal hander already been installed? + +struct sigaction sa ; // our sigcld signal handler +struct sigaction osa; // original (R) signal hander + +void sigchld_hander(int dummy) +{ + int st; + while (wait3(&st, WNOHANG, NULL) > 0); +} + + +void R_install_sigcld_handler() +{ + int ret; + + if(installed==0) + { + Rprintf ("Installing SIGCHLD signal handler..."); + //sa.sa_handler = sigchld_handler; + sa.sa_handler = waiter; + //sigfillset (&sa.sa_mask); + //sa.sa_flags = SA_RESTART; + ret = sigaction (SIGCHLD, &sa, &osa); + if (ret < 0) + { + error("Cannot set signal handler"); + } + installed=-1; + Rprintf("Done.\n"); + } + else + { + warning("SIGCLD signal handler already installed"); + } + +} + +void R_restore_sigcld_handler() +{ + int ret; + + if(installed==-1) + { + Rprintf ("Restoring original SIGCHLD signal handler..."); + ret = sigaction (SIGCHLD, &osa, &sa); + if (ret < 0) + { + error("Cannot reset signal handler"); + } + installed=0; + Rprintf("Done.\n"); + } + else + { + warning("SIGCLD signal handler not installed: cannot reset."); + } + +} Added: trunk/fork/tests/test_many_fork.R =================================================================== --- trunk/fork/tests/test_many_fork.R (rev 0) +++ trunk/fork/tests/test_many_fork.R 2007-02-14 22:48:47 UTC (rev 1053) @@ -0,0 +1,20 @@ +library(fork) + +# ignore sigchld signals so child processes will die cleanly +#signal("SIGCHLD","ignore") + +# start signal handler +.C("R_install_sigcld_handler") + +for(i in 1:100) + { + pid = fork(slave=NULL) + if(pid==0) { + cat("Hi from the child process\n"); exit() + } else { + cat("Hi from the parent process\n"); + } + } + +# remove signal handler +.C("R_restore_sigcld_handler") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-02-08 23:05:19
|
Revision: 1052 http://svn.sourceforge.net/r-gregmisc/?rev=1052&view=rev Author: warnes Date: 2007-02-08 15:05:14 -0800 (Thu, 08 Feb 2007) Log Message: ----------- Bump version number Modified Paths: -------------- trunk/gplots/DESCRIPTION Modified: trunk/gplots/DESCRIPTION =================================================================== --- trunk/gplots/DESCRIPTION 2007-02-08 22:03:16 UTC (rev 1051) +++ trunk/gplots/DESCRIPTION 2007-02-08 23:05:14 UTC (rev 1052) @@ -4,7 +4,7 @@ Depends: R (>= 1.9.0), gtools, gdata, stats Recommends: datasets Suggests: gtools, gdata -Version: 2.3.2 +Version: 2.4.0 Author: Gregory R. Warnes. Includes R source code and/or documentation contributed by Ben Bolker and Thomas Lumley Maintainer: Gregory R. Warnes <wa...@bs...> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-02-08 22:03:45
|
Revision: 1051 http://svn.sourceforge.net/r-gregmisc/?rev=1051&view=rev Author: warnes Date: 2007-02-08 14:03:16 -0800 (Thu, 08 Feb 2007) Log Message: ----------- Update documentation for textplot() Modified Paths: -------------- trunk/gplots/man/textplot.Rd Modified: trunk/gplots/man/textplot.Rd =================================================================== --- trunk/gplots/man/textplot.Rd 2007-02-08 21:56:22 UTC (rev 1050) +++ trunk/gplots/man/textplot.Rd 2007-02-08 22:03:16 UTC (rev 1051) @@ -23,7 +23,9 @@ \method{textplot}{matrix}(object, halign = c("center", "left", "right"), valign = c("center", "top", "bottom"), cex, cmar = 2, rmar = 0.5, show.rownames = TRUE, show.colnames = TRUE, - hadj = 1, vadj = 1, mar, ...) + hadj = 1, vadj = 1, mar = c(1, 1, 4, 1) + 0.1, + col.data = par("col"), col.rownames = par("col"), + col.colnames = par("col"), ...) } \arguments{ \item{object}{Object to be displayed.} @@ -51,6 +53,14 @@ \item{hadj,vadj}{Vertical and horizontal location of elements within matrix cells. These have the same meaning as the \code{adj} graphics paramter (see \code{\link{par}}).} + \item{col.data}{Colors for data elements. If a single value is + provided, all data elements will be the same color. If a matrix + matching the dimensions of the data is provided, each data element + will receive the specified color.} + \item{col.col.rownames, col.colnames}{Colors for row names and column + names, respectively. Either may be specified as a scalar or a + vector of appropriate length.} + } \item{\dots}{ Optional arguments passed to the text plotting command or specialied object methods} } @@ -106,6 +116,13 @@ par(mfrow=c(1,1)) +# color control example +cols <- c("red", "green", "magenta", "forestgreen") +mat <- cbind(name=cols, t(col2rgb(cols)), hex=col2hex(cols)) + +textplot(mat, + col.data=matrix(cols, nrow=length(cols), byrow=FALSE, ncol=5), + ) } } \keyword{hplot} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-02-08 21:56:29
|
Revision: 1050 http://svn.sourceforge.net/r-gregmisc/?rev=1050&view=rev Author: warnes Date: 2007-02-08 13:56:22 -0800 (Thu, 08 Feb 2007) Log Message: ----------- Add col2rgb() function to convert color names to rgb hex codes Added Paths: ----------- trunk/gplots/R/col2hex.R trunk/gplots/man/col2hex.Rd Added: trunk/gplots/R/col2hex.R =================================================================== --- trunk/gplots/R/col2hex.R (rev 0) +++ trunk/gplots/R/col2hex.R 2007-02-08 21:56:22 UTC (rev 1050) @@ -0,0 +1,9 @@ +col2hex <- function(cname) + { + colMat <- col2rgb(cname) + rgb( + red=colMat[1,]/255, + blue=colMat[2,]/255, + green=colMat[3,]/255 + ) + } Added: trunk/gplots/man/col2hex.Rd =================================================================== --- trunk/gplots/man/col2hex.Rd (rev 0) +++ trunk/gplots/man/col2hex.Rd 2007-02-08 21:56:22 UTC (rev 1050) @@ -0,0 +1,24 @@ +\name{col2hex} +\alias{col2hex} +\title{Convert color names to hex RGB strings} +\description{ + Convert color names to hex RGB strings +} +\usage{ +col2hex(cname) +} +\arguments{ + \item{cname}{Color name(s)} +} +\value{ + Character vector giving the hex color code translation of the provided + color names. +} +\author{Gregory R. Warnes} +\seealso{ + \code{\link{col2rgb}}, \code{\link{colors}}, \code{\link{rgb}} + } +\examples{ +col2hex(c("red","yellow","lightgrey")) +} +\keyword{color} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-02-08 21:32:59
|
Revision: 1049 http://svn.sourceforge.net/r-gregmisc/?rev=1049&view=rev Author: warnes Date: 2007-02-08 13:32:32 -0800 (Thu, 08 Feb 2007) Log Message: ----------- Add paramaeters 'col.data', 'col.rows', and 'col.columns' to textplot.matrix to allow specification of the color of the matrix data, rows, and columns. Modified Paths: -------------- trunk/gplots/R/textplot.R Modified: trunk/gplots/R/textplot.R =================================================================== --- trunk/gplots/R/textplot.R 2007-02-08 16:56:57 UTC (rev 1048) +++ trunk/gplots/R/textplot.R 2007-02-08 21:32:32 UTC (rev 1049) @@ -35,6 +35,9 @@ hadj=1, vadj=1, mar= c(1,1,4,1)+0.1, + col.data=par("col"), + col.rownames=par("col"), + col.colnames=par("col"), ... ) { @@ -43,6 +46,22 @@ else object <- as.matrix(object) + # check dimensions of col.data, col.rownames, col.colnames + if(length(col.data)==1) + col.data <- matrix(col.data, nrow=nrow(object), ncol=ncol(object)) + else + if( nrow(col.data)!=nrow(object) || ncol(col.data)!=ncol(object) ) + stop("Dimensions of 'col.data' do not match dimensions of 'object'.") + + if(length(col.rownames)==1) + col.rownames <- rep(col.rownames, nrow(object)) + + if(length(col.colnames)==1) + if(show.rownames) + col.colnames <- rep(col.colnames, ncol(object)+1) + else + col.colnames <- rep(col.colnames, ncol(object)) + halign=match.arg(halign) valign=match.arg(valign) @@ -63,15 +82,17 @@ rownames(object) <- paste( "[", 1:nrow(object), ",]", sep="") - # extend the matrix to include them + # extend the matrix to include row and column labels if( show.rownames ) { object <- cbind( rownames(object), object ) + col.data <- cbind( col.rownames, col.data ) + } if( show.colnames ) { - object <- rbind( colnames(object), object ) + col.data <- rbind( col.colnames, col.data ) } # set the character size @@ -143,9 +164,11 @@ for(j in 1:nrow(object)) { ypos<-y-(j-1)*rowheight if( (show.rownames && i==1) || (show.colnames && j==1) ) - text(xpos, ypos, object[j,i], adj=c(hadj,vadj), cex=cex, font=2, ... ) + text(xpos, ypos, object[j,i], adj=c(hadj,vadj), cex=cex, font=2, + col=col.data[j,i], ... ) else - text(xpos, ypos, object[j,i], adj=c(hadj,vadj), cex=cex, font=1, ... ) + text(xpos, ypos, object[j,i], adj=c(hadj,vadj), cex=cex, font=1, + col=col.data[j,i], ... ) } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-02-08 17:14:08
|
Revision: 1048 http://svn.sourceforge.net/r-gregmisc/?rev=1048&view=rev Author: warnes Date: 2007-02-08 08:56:57 -0800 (Thu, 08 Feb 2007) Log Message: ----------- Add parameters to control line width and line type. Modified Paths: -------------- trunk/gplots/R/bandplot.R Modified: trunk/gplots/R/bandplot.R =================================================================== --- trunk/gplots/R/bandplot.R 2007-02-05 23:21:52 UTC (rev 1047) +++ trunk/gplots/R/bandplot.R 2007-02-08 16:56:57 UTC (rev 1048) @@ -6,18 +6,22 @@ sd=c(-2:2), sd.col=c("lightblue","blue","red", "blue","lightblue"), + sd.lwd=c(1,2,3,2,1), + sd.lty=c(2,1,1,1,2), method="frac", width=1/5, n=50 ) { if(length(sd.col)<length(sd)) sd <-rep(sd.col,length=length(sd)) + if(length(sd.lwd)<length(sd)) sd <-rep(sd.lwd,length=length(sd)) + if(length(sd.lty)<length(sd)) sd <-rep(sd.lty,length=length(sd)) if(!add) { m <- match.call(expand.dots = TRUE) m$width <- m$add <- m$sd <- m$sd.col <- NULL - m$method <- m$n <- NULL + m$method <- m$n <- m$sd.lty <- m$sd.lwd <- NULL m[[1]] <- as.name("plot") mf <- eval(m, parent.frame()) } @@ -31,16 +35,21 @@ else mean(x)+sd*sqrt(var(x)) - sdplot <- function(S, COL) + sdplot <- function(S, COL, LWD, LTY) { where <- wapply(x,y,CL,sd=S,width=width,method=method,n=n) - lines(where,col=COL,...) + lines(where,col=COL,lwd=LWD,lty=LTY,...) where } stdevs <- list() for( i in 1:length(sd) ) - stdevs[[as.character(sd[i])]] <- sdplot( sd[i], sd.col[i] ) + stdevs[[as.character(sd[i])]] <- sdplot( + sd[i], + COL=sd.col[i], + LWD=sd.lwd[i], + LTY=sd.lty[i] + ) invisible( stdevs ) } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-02-05 23:21:53
|
Revision: 1047 http://svn.sourceforge.net/r-gregmisc/?rev=1047&view=rev Author: warnes Date: 2007-02-05 15:21:52 -0800 (Mon, 05 Feb 2007) Log Message: ----------- Add documentation for signal() Modified Paths: -------------- trunk/fork/man/signal.Rd Modified: trunk/fork/man/signal.Rd =================================================================== --- trunk/fork/man/signal.Rd 2007-02-05 23:21:39 UTC (rev 1046) +++ trunk/fork/man/signal.Rd 2007-02-05 23:21:52 UTC (rev 1047) @@ -15,8 +15,8 @@ \details{ It is occasionally necessary to instruct the R process to ignore certain signals. This function allows changing the status of a signal - to either igore the signal (SIG_IGN="ignore") or to the OS's default - handler (SIG_DFL="default") + to either igore the signal (SIG\_IGN="ignore") or to the OS's default + handler (SIG\_DFL="default") } \value{ Nothing of interest. @@ -29,7 +29,7 @@ } \seealso{ \code{\link{sigval}}, \code{\link{fork}} } \examples{ - +\dontrun{ # Ignore child termination signals for forked processes signal("SIGCHLD","ignore") @@ -42,8 +42,8 @@ exit() # force process to die } } - } +} % Add one or more standard keywords, see file 'KEYWORDS' in the % R documentation directory. \keyword{programming} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-02-05 23:21:42
|
Revision: 1046 http://svn.sourceforge.net/r-gregmisc/?rev=1046&view=rev Author: warnes Date: 2007-02-05 15:21:39 -0800 (Mon, 05 Feb 2007) Log Message: ----------- Add signal() to example for fork() Modified Paths: -------------- trunk/fork/man/fork.Rd Modified: trunk/fork/man/fork.Rd =================================================================== --- trunk/fork/man/fork.Rd 2007-02-05 23:21:13 UTC (rev 1045) +++ trunk/fork/man/fork.Rd 2007-02-05 23:21:39 UTC (rev 1046) @@ -162,10 +162,12 @@ close(con2) } +\dontrun{ # Important: if we aren't going to explicitly wait() for the child # process to exit, we need to tell the OS that we are ignoring child # process signals so it will let us die cleanly. signal("SIGCHLD","ignore") +} # fork off the process pid <- fork(recieve) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-02-05 23:21:14
|
Revision: 1045 http://svn.sourceforge.net/r-gregmisc/?rev=1045&view=rev Author: warnes Date: 2007-02-05 15:21:13 -0800 (Mon, 05 Feb 2007) Log Message: ----------- Bump version number Modified Paths: -------------- trunk/fork/DESCRIPTION Modified: trunk/fork/DESCRIPTION =================================================================== --- trunk/fork/DESCRIPTION 2007-02-05 23:17:07 UTC (rev 1044) +++ trunk/fork/DESCRIPTION 2007-02-05 23:21:13 UTC (rev 1045) @@ -1,6 +1,6 @@ Package: fork Title: R functions for handling multiple processes. -Version: 1.0.3 +Version: 1.1.0 Author: Gregory R. Warnes <wa...@bs...> Description: These functions provides simple wrappers around the Unix process management API calls: fork, wait, waitpid, kill, and _exit. This This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-02-05 23:17:33
|
Revision: 1044 http://svn.sourceforge.net/r-gregmisc/?rev=1044&view=rev Author: warnes Date: 2007-02-05 15:17:07 -0800 (Mon, 05 Feb 2007) Log Message: ----------- Handle arguments better Modified Paths: -------------- trunk/fork/R/signal.R Modified: trunk/fork/R/signal.R =================================================================== --- trunk/fork/R/signal.R 2007-02-05 23:08:43 UTC (rev 1043) +++ trunk/fork/R/signal.R 2007-02-05 23:17:07 UTC (rev 1044) @@ -1,27 +1,24 @@ # $Id: kill.R 340 2004-05-25 19:12:32Z warnes $ -signal <- function(signal, action=c("ignore","restore") ) +signal <- function(signal, action=c("ignore","default") ) { - action=match.args(action) + action=match.arg(action) if(is.character(signal)) - sig=sigval(signal)$val - else (is.numeric(signal) && !is.na(signal)) - sig=signal + sig <- sigval(signal)$val + else if(is.numeric(signal) && !is.na(signal)) + sig <- signal else stop("Illegal value for signal") act <- switch( action, "ignore"=0, - "restore"=1 + "default"=1 ) - - msg1 = - .C( "Rfork_signal", - as.integer(signal), + as.integer(sig), as.integer(act), PACKAGE="fork" ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-02-05 23:10:39
|
Revision: 1043 http://svn.sourceforge.net/r-gregmisc/?rev=1043&view=rev Author: warnes Date: 2007-02-05 15:08:43 -0800 (Mon, 05 Feb 2007) Log Message: ----------- Add signal() command to allow ignoring signals Modified Paths: -------------- trunk/fork/DESCRIPTION trunk/fork/R/signame.R trunk/fork/man/fork.Rd trunk/fork/man/signame.Rd trunk/fork/src/fork.c Added Paths: ----------- trunk/fork/R/signal.R trunk/fork/man/signal.Rd Modified: trunk/fork/DESCRIPTION =================================================================== --- trunk/fork/DESCRIPTION 2007-01-28 10:42:24 UTC (rev 1042) +++ trunk/fork/DESCRIPTION 2007-02-05 23:08:43 UTC (rev 1043) @@ -1,6 +1,6 @@ Package: fork Title: R functions for handling multiple processes. -Version: 1.0.2 +Version: 1.0.3 Author: Gregory R. Warnes <wa...@bs...> Description: These functions provides simple wrappers around the Unix process management API calls: fork, wait, waitpid, kill, and _exit. This Added: trunk/fork/R/signal.R =================================================================== --- trunk/fork/R/signal.R (rev 0) +++ trunk/fork/R/signal.R 2007-02-05 23:08:43 UTC (rev 1043) @@ -0,0 +1,30 @@ +# $Id: kill.R 340 2004-05-25 19:12:32Z warnes $ + +signal <- function(signal, action=c("ignore","restore") ) + { + action=match.args(action) + + if(is.character(signal)) + sig=sigval(signal)$val + else (is.numeric(signal) && !is.na(signal)) + sig=signal + else + stop("Illegal value for signal") + + act <- switch( + action, + "ignore"=0, + "restore"=1 + ) + + msg1 = + + .C( + "Rfork_signal", + as.integer(signal), + as.integer(act), + PACKAGE="fork" + ) + invisible() + } + Modified: trunk/fork/R/signame.R =================================================================== --- trunk/fork/R/signame.R 2007-01-28 10:42:24 UTC (rev 1042) +++ trunk/fork/R/signame.R 2007-02-05 23:08:43 UTC (rev 1043) @@ -20,7 +20,8 @@ val=integer(1), desc=character(1), PACKAGE="fork") - unlist(retval) + #retval <- unlist(retval) + retval } siglist <- function() Modified: trunk/fork/man/fork.Rd =================================================================== --- trunk/fork/man/fork.Rd 2007-01-28 10:42:24 UTC (rev 1042) +++ trunk/fork/man/fork.Rd 2007-02-05 23:08:43 UTC (rev 1043) @@ -162,8 +162,15 @@ close(con2) } +# Important: if we aren't going to explicitly wait() for the child +# process to exit, we need to tell the OS that we are ignoring child +# process signals so it will let us die cleanly. +signal("SIGCHLD","ignore") +# fork off the process pid <- fork(recieve) + +# start sending... send() } } Added: trunk/fork/man/signal.Rd =================================================================== --- trunk/fork/man/signal.Rd (rev 0) +++ trunk/fork/man/signal.Rd 2007-02-05 23:08:43 UTC (rev 1043) @@ -0,0 +1,49 @@ +\name{signal} +\alias{signal} +\title{Enable or disable handling of signals} +\description{ + This function allows enabling or disabling handling of the specified signal. +} +\usage{ +signal(signal, action = c("ignore", "default")) +} +\arguments{ + \item{signal}{Signal handler to manipulate, either as a numeric id or + character mnemonic} + \item{action}{Either "ignore" or "default"} +} +\details{ + It is occasionally necessary to instruct the R process to ignore + certain signals. This function allows changing the status of a signal + to either igore the signal (SIG_IGN="ignore") or to the OS's default + handler (SIG_DFL="default") +} +\value{ + Nothing of interest. +} +\references{ See the unix man page for "signal" for more information} +\author{Gregory R. Warnes \email{gre...@ro...} } +\note{ + Be very careful with this function. It can be used to totally + confuse the R process. +} +\seealso{ \code{\link{sigval}}, \code{\link{fork}} } +\examples{ + +# Ignore child termination signals for forked processes +signal("SIGCHLD","ignore") + +# Fork off a child process to say "Hi!". + { + pid = fork(slave=NULL) + if(pid==0) { + # only runs in the child process + cat("Hi from the child process!\n"); + exit() # force process to die + } + } + +} +% Add one or more standard keywords, see file 'KEYWORDS' in the +% R documentation directory. +\keyword{programming} Modified: trunk/fork/man/signame.Rd =================================================================== --- trunk/fork/man/signame.Rd 2007-01-28 10:42:24 UTC (rev 1042) +++ trunk/fork/man/signame.Rd 2007-02-05 23:08:43 UTC (rev 1043) @@ -22,7 +22,7 @@ compile time. } \value{ - A vector (\code{signame}, \code{sigval}) or data frame + A list (\code{signame}, \code{sigval}) or data frame (\code{siglist}) containing the components: \item{name}{Symbolic name} \item{val}{Integer value} Modified: trunk/fork/src/fork.c =================================================================== --- trunk/fork/src/fork.c 2007-01-28 10:42:24 UTC (rev 1042) +++ trunk/fork/src/fork.c 2007-02-05 23:08:43 UTC (rev 1043) @@ -266,3 +266,15 @@ return list; } +void Rfork_signal(int *sig, int *action) +{ + sig_t func; + + if(*action==0) + func = SIG_IGN; + else + func = SIG_DFL; + + signal( *sig, func ); +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ar...@us...> - 2007-01-28 10:42:27
|
Revision: 1042 http://svn.sourceforge.net/r-gregmisc/?rev=1042&view=rev Author: arnima Date: 2007-01-28 02:42:24 -0800 (Sun, 28 Jan 2007) Log Message: ----------- Throw warnings rather than errors Modified Paths: -------------- trunk/gdata/R/keep.R Modified: trunk/gdata/R/keep.R =================================================================== --- trunk/gdata/R/keep.R 2007-01-27 11:36:34 UTC (rev 1041) +++ trunk/gdata/R/keep.R 2007-01-28 10:42:24 UTC (rev 1042) @@ -1,14 +1,20 @@ keep <- function(..., list=character(0), sure=FALSE) { if(missing(...) && missing(list)) - stop("Keep something, or use rm(list=ls()) to clear workspace.") + { + warning("Keep something, or use rm(list=ls()) to clear workspace. ", + "Nothing was removed.") + return(invisible(NULL)) + } names <- as.character(substitute(list(...)))[-1] list <- c(list, names) keep.elements <- match(list, ls(1)) - if(any(is.na(keep.elements))) - stop("You tried to keep \"", list[which(is.na(keep.elements))[1]], - "\" which doesn't exist in workspace. Nothing was removed.", sep="") + { + warning("You tried to keep \"", list[which(is.na(keep.elements))[1]], + "\" which doesn't exist in workspace. Nothing was removed.", sep="") + return(invisible(NULL)) + } if(sure) rm(list=ls(1)[-keep.elements], pos=1) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ar...@us...> - 2007-01-27 11:36:35
|
Revision: 1041 http://svn.sourceforge.net/r-gregmisc/?rev=1041&view=rev Author: arnima Date: 2007-01-27 03:36:34 -0800 (Sat, 27 Jan 2007) Log Message: ----------- Meaningful error message is given when requested object does not exist Modified Paths: -------------- trunk/gdata/R/keep.R Modified: trunk/gdata/R/keep.R =================================================================== --- trunk/gdata/R/keep.R 2007-01-27 11:35:12 UTC (rev 1040) +++ trunk/gdata/R/keep.R 2007-01-27 11:36:34 UTC (rev 1041) @@ -1,5 +1,3 @@ -# $Id$ - keep <- function(..., list=character(0), sure=FALSE) { if(missing(...) && missing(list)) @@ -8,9 +6,13 @@ list <- c(list, names) keep.elements <- match(list, ls(1)) - if(sure == FALSE) + if(any(is.na(keep.elements))) + stop("You tried to keep \"", list[which(is.na(keep.elements))[1]], + "\" which doesn't exist in workspace. Nothing was removed.", sep="") + + if(sure) + rm(list=ls(1)[-keep.elements], pos=1) + else return(ls(1)[-keep.elements]) - else - rm(list=ls(1)[-keep.elements], pos=1) } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ar...@us...> - 2007-01-27 11:35:17
|
Revision: 1040 http://svn.sourceforge.net/r-gregmisc/?rev=1040&view=rev Author: arnima Date: 2007-01-27 03:35:12 -0800 (Sat, 27 Jan 2007) Log Message: ----------- is.* tests that return NA are not reported is.what recursion is avoided Modified Paths: -------------- trunk/gdata/R/is.what.R Modified: trunk/gdata/R/is.what.R =================================================================== --- trunk/gdata/R/is.what.R 2006-12-06 19:20:46 UTC (rev 1039) +++ trunk/gdata/R/is.what.R 2007-01-27 11:35:12 UTC (rev 1040) @@ -3,7 +3,7 @@ do.test <- function(test, object) { result <- try(get(test)(object), silent=TRUE) - if(!is.logical(result) || length(result)!=1) + if(!is.logical(result) || is.na(result) || length(result)!=1) result <- NULL return(result) } @@ -14,20 +14,13 @@ ## Narrow to functions is.functions <- is.names[sapply(is.names, function(x) is.function(get(x)))] - tests <- sort(unique(is.functions)) + tests <- sort(unique(is.functions[is.functions!="is.what"])) results <- suppressWarnings(unlist(sapply(tests, do.test, object=object))) if(verbose) - { - results <- as.character(results) - results[results=="TRUE"] <- "T" - results[results=="FALSE"] <- "." - output <- data.frame(is=results) - } + output <- data.frame(is=ifelse(results,"T",".")) else - { output <- names(results)[results] - } return(output) } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2006-12-05 16:54:58
|
Revision: 1038 http://svn.sourceforge.net/r-gregmisc/?rev=1038&view=rev Author: warnes Date: 2006-12-05 08:54:56 -0800 (Tue, 05 Dec 2006) Log Message: ----------- Some corrections from review of similar article for RNEWS Modified Paths: -------------- trunk/exp.ssize/DESCRIPTION trunk/exp.ssize/inst/doc/ssize.pdf trunk/exp.ssize/inst/doc/ssize.tex Modified: trunk/exp.ssize/DESCRIPTION =================================================================== --- trunk/exp.ssize/DESCRIPTION 2006-12-05 16:52:38 UTC (rev 1037) +++ trunk/exp.ssize/DESCRIPTION 2006-12-05 16:54:56 UTC (rev 1038) @@ -1,7 +1,6 @@ Package: ssize.sim Title: Estimate Effectivenes of Microarry Sample Size Estimation via Simulation -Version: 1.0.0 -Date: 2005-01-14 +Version: 1.0.1 Author: Peng Liu and Gregory R. WarneS Description: Functions for evaluating the performance microarray sample size estimation procedures via simulation, as used in Modified: trunk/exp.ssize/inst/doc/ssize.pdf =================================================================== (Binary files differ) Modified: trunk/exp.ssize/inst/doc/ssize.tex =================================================================== --- trunk/exp.ssize/inst/doc/ssize.tex 2006-12-05 16:52:38 UTC (rev 1037) +++ trunk/exp.ssize/inst/doc/ssize.tex 2006-12-05 16:54:56 UTC (rev 1038) @@ -36,8 +36,8 @@ \begin{abstract} -RNA Expression Microarray technology is widely applied in biomedical -and pharmaceutical research. The huge number of RNA concentrations +mRNA expression microarray technology is widely applied in biomedical +and pharmaceutical research. The huge number of mRNA concentrations estimated for each sample make it difficult to apply traditional sample size calculation techniques and has left most practitioners to rely on rule-of-thumb techniques. In this paper, we describe and @@ -49,11 +49,13 @@ been appropriately selected. Although we demonstrate sample size calculation only for the two-sample pooled t-test, it is trivial to substitute an alternative sample size formula appropriate to the -problem at hand. The described method has been implemented in the -\texttt{ssize} R package, which is available from the Bioconductor -project (\url{http://www.bioconductor.org}) web site. +problem at hand. +%The described method has been implemented in the +%\texttt{ssize} R package, which is available from the Bioconductor +%project (\url{http://www.bioconductor.org}) web site. + %\subsection{Motivation:} %Microarray technology is widely applied in biomedical and @@ -122,11 +124,11 @@ High-throughput microarray experiments allow the measurement of expression levels for tens of thousands of genes simultaneously. These experiments have been used in many disciplines of biological -research, including as neuroscience \citep{Mandel03}, +research, including neuroscience \citep{Mandel03}, pharmacogenomic research, genetic disease and cancer diagnosis \citep{Heller02}. As a tool for estimating gene expression and single nucleotide polymorphism (SNP) genotyping, microarrays produce -huge amounts of data which are providing important new insights. +huge amounts of data which can provide important new insights. Microarray experiments are rather costly in terms of materials (RNA sample, reagents, chip, etc), laboratory manpower, and data This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2006-12-05 16:52:41
|
Revision: 1037 http://svn.sourceforge.net/r-gregmisc/?rev=1037&view=rev Author: warnes Date: 2006-12-05 08:52:38 -0800 (Tue, 05 Dec 2006) Log Message: ----------- Remove nws from repository Removed Paths: ------------- trunk/nws/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2006-12-05 16:51:38
|
Revision: 1036 http://svn.sourceforge.net/r-gregmisc/?rev=1036&view=rev Author: warnes Date: 2006-12-05 08:51:30 -0800 (Tue, 05 Dec 2006) Log Message: ----------- Remove qvalue from repository Removed Paths: ------------- trunk/qvalue/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gg...@us...> - 2006-11-30 21:38:05
|
Revision: 1035 http://svn.sourceforge.net/r-gregmisc/?rev=1035&view=rev Author: ggorjan Date: 2006-11-30 13:38:01 -0800 (Thu, 30 Nov 2006) Log Message: ----------- minor commet to the code Modified Paths: -------------- trunk/gdata/R/unknown.R Modified: trunk/gdata/R/unknown.R =================================================================== --- trunk/gdata/R/unknown.R 2006-11-30 21:36:40 UTC (rev 1034) +++ trunk/gdata/R/unknown.R 2006-11-30 21:38:01 UTC (rev 1035) @@ -1,8 +1,8 @@ ### unknown.R ###------------------------------------------------------------------------ ### What: Change given unknown value to NA and vice versa -### $Id:$ -### Time-stamp: <2006-10-30 18:06:17 ggorjan> +### $Id$ +### Time-stamp: <2006-11-28 15:02:19 ggorjan> ###------------------------------------------------------------------------ ### {{{ isUnknown @@ -184,7 +184,7 @@ if(unkN < n) { if(unkNamesNullTest | defInNames) { - if(defInNames) { + if(defInNames) { # handling .default names(def) <- NULL unknownDef <- rep(def, length=(n - unkN)) names(unknownDef) <- namesX[!(namesX %in% unkNames)] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |