I am generating 1,000 replicates of 10,000 of these 2 x 3 tables but R cannot seem to save it. Its over 1 Gig. Any ideas on how I can store this large amount of data? Should I use a list or a matrix?
Jim On Wed, Jun 22, 2011 at 10:21 PM, Mike Miller <mbmille...@gmail.com> wrote: > On Thu, 23 Jun 2011, David Duffy wrote: > > I am interested in simulating 10,000 2 x 3 tables for SNPs data with the >>> Hardy Weinberg formulation. Is there a quick way to do this? I am assuming >>> that the minor allelle frequency is uniform in (0.05, 0.25). >>> >> >> rmultinom() with HWE expectations >> > > > I'm also unsure of what the 2x3 table is (what are the rows?), and David > gave you a good answer for how to make tabular data, but I just thought I'd > add some info for those who may be interested... > > If you want to make genotype data in the form of minor allele counts under > HW, you can use rbinom() with size=2 and prob=MAF. > > Suppose variable "n" is the number of subjects for whom data is to be > generated, "maf" is a vector of minor allele frequencies, and "m" is the > length of maf (i.e., the number of markers to be generated. Then this will > produce a data matrix (subjects by markers): > > maf <- c( .1, .2, .5 ) >> n <- 7 >> m <- length( maf ) >> t( matrix( rbinom( n*m, 2, maf ), m, n ) ) >> > [,1] [,2] [,3] > [1,] 0 0 2 > [2,] 0 1 1 > [3,] 1 0 2 > [4,] 0 2 1 > [5,] 1 1 1 > [6,] 0 1 2 > [7,] 0 0 1 > > Of course, when data are produced that way, the markers are in linkage > equilibrium (an unfortunate term meaning that the genotypes for pairs of > markers are not associated). > > Mike > > -- > Michael B. Miller, Ph.D. > Minnesota Center for Twin and Family Research > Department of Psychology > University of Minnesota > -- Thanks, Jim. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.