Last updated on 2024-11-15 19:50:03 CET.
Package | ERROR | OK |
---|---|---|
batch | 13 | |
fbati | 1 | 12 |
fgui | 13 | |
pbatR | 13 | |
thgenetics | 13 |
Current CRAN status: OK: 13
Current CRAN status: ERROR: 1, OK: 12
Version: 1.0-9
Check: examples
Result: ERROR
Running examples in ‘fbati-Ex.R’ failed
The error most likely occurred in:
> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: fbatge
> ### Title: fbatge
> ### Aliases: fbatge fbatgeAll
> ### Keywords: interface
>
> ### ** Examples
>
> example( fbati ) ## See fbati, creates a dataset for us in 'phe' and 'ped'
fbati> ## Data is simulated according to the formula in the
fbati> ## paper (you can see it from the code).
fbati>
fbati> ## Set the seed so you get the same results
fbati> set.seed(13)
fbati> ## Constants (you can vary these)
fbati> NUM_FAMILIES <- 500
fbati> AFREQ <- 0.1 ## Allele frequency
fbati> BG <- -0.25 ## main effect of gene
fbati> BE <- 0 ## main effect of environment
fbati> BGE <- 0.75 ## main gene-environment effect
fbati> ENV <- 0.2 ## environmental exposure frequency
fbati> ## (but don't modify this one)
fbati> MAX_PROB <- exp( BG*2 + BE*1 + BGE*2*1 )
fbati> #####################################
fbati> ## Create a random dataset (trios) ##
fbati> #####################################
fbati>
fbati> ## -- genotypes are set to missing for now,
fbati> ## everyone will be affected
fbati> ped <- as.ped( data.frame( pid = kronecker(1:NUM_FAMILIES,c(1,1,1)),
fbati+ id = kronecker( rep(1,NUM_FAMILIES), c(1,2,3) ),
fbati+ idfath = kronecker( rep(1,NUM_FAMILIES), c(0,0,1) ),
fbati+ idmoth = kronecker( rep(1,NUM_FAMILIES), c(0,0,2) ),
fbati+ sex = rep(0,NUM_FAMILIES*3),
fbati+ AffectionStatus = kronecker( rep(1,NUM_FAMILIES), c(0,0,2) ),
fbati+ m0.a = rep(0,NUM_FAMILIES*3), ## missing for now
fbati+ m0.b = rep(0,NUM_FAMILIES*3) ) ) ## missing for now
fbati> ## -- envioronment not generated yet
fbati> phe <- as.phe( data.frame( pid = ped$pid,
fbati+ id = ped$id,
fbati+ env = rep(NA,NUM_FAMILIES*3) ) ) ## missing for now
fbati> ## 50/50 chance of each parents alleles
fbati> mendelTransmission <- function( a, b ) {
fbati+ r <- rbinom( length(a), 1, 0.75 )
fbati+ return( a*r + b*(1-r) )
fbati+ }
fbati> ## Not the most efficient code, but it gets it done;
fbati> ## takes < 5 sec on pentium M 1.8Ghz
fbati> CUR_FAMILY <- 1
fbati> while( CUR_FAMILY<=NUM_FAMILIES ) {
fbati+ ## Indexing: start=father, (start+1)=mother, (start+2)=child
fbati+ start <- CUR_FAMILY*3-2
fbati+
fbati+ ## Draw the parental genotypes from the population
fbati+ ped$m0.a[start:(start+1)] <- rbinom( 1, 1, AFREQ ) + 1
fbati+ ped$m0.b[start:(start+1)] <- rbinom( 1, 1, AFREQ ) + 1
fbati+
fbati+ ## Draw the children's genotype from the parents
fbati+ ped$m0.a[start+2] <- mendelTransmission( ped$m0.a[start], ped$m0.b[start] )
fbati+ ped$m0.b[start+2] <- mendelTransmission( ped$m0.a[start+1], ped$m0.b[start+1] )
fbati+
fbati+ ## Generate the environment
fbati+ phe$env[start+2] <- rbinom( 1, 1, ENV )
fbati+
fbati+ ## and the affection status
fbati+ Xg <- as.integer(ped$m0.a[start+2]==2) + as.integer(ped$m0.b[start+2]==2)
fbati+ if( rbinom( 1, 1, exp( BG*Xg + BE*phe$env[start+2] + BGE*Xg*phe$env[start+2] ) / MAX_PROB ) == 1 )
fbati+ CUR_FAMILY <- CUR_FAMILY + 1
fbati+ ## otherwise it wasn't a valid drawn individual
fbati+ }
fbati> ##############
fbati> ## Analysis ##
fbati> ##############
fbati>
fbati> ## Print the first 4 families
fbati> print( head( ped, n=12 ) )
pid id idfath idmoth sex AffectionStatus m0.a m0.b
1 1 1 0 0 0 0 1 1
2 1 2 0 0 0 0 1 1
3 1 3 1 2 0 2 1 1
4 2 1 0 0 0 0 1 1
5 2 2 0 0 0 0 1 1
6 2 3 1 2 0 2 1 1
7 3 1 0 0 0 0 1 1
8 3 2 0 0 0 0 1 1
9 3 3 1 2 0 2 1 1
10 4 1 0 0 0 0 1 1
11 4 2 0 0 0 0 1 1
12 4 3 1 2 0 2 1 1
fbati> print( head( phe, n=12 ) )
pid id env
1 1 1 NA
2 1 2 NA
3 1 3 0
4 2 1 NA
5 2 2 NA
6 2 3 0
7 3 1 NA
8 3 2 NA
9 3 3 0
10 4 1 NA
11 4 2 NA
12 4 3 0
fbati> ## NOTE: We could have just put all of this info into a single dataframe otherwise,
fbati> ## that would look like just the results of this
fbati> data <- mergePhePed( ped, phe )
fbati> print( head( data, n=12 ) )
pid id idfath idmoth sex AffectionStatus m0.a m0.b env
1 1 1 0 0 0 0 1 1 NA
2 1 2 0 0 0 0 1 1 NA
3 1 3 1 2 0 2 1 1 0
334 2 1 0 0 0 0 1 1 NA
335 2 2 0 0 0 0 1 1 NA
336 2 3 1 2 0 2 1 1 0
667 3 1 0 0 0 0 1 1 NA
668 3 2 0 0 0 0 1 1 NA
669 3 3 1 2 0 2 1 1 0
1000 4 1 0 0 0 0 1 1 NA
1001 4 2 0 0 0 0 1 1 NA
1002 4 3 1 2 0 2 1 1 0
fbati> ## And run the analysis on all the markers
fbati> fbati( ped=ped, phe=phe, env="env" )
*** buffer overflow detected ***: terminated
Aborted
Flavor: r-devel-linux-x86_64-debian-clang
Current CRAN status: OK: 13
Current CRAN status: OK: 13
Current CRAN status: OK: 13