#!/usr/bin/Rscript library(MASS) generate_testdata <- function(n,c=0.75) { Sigma <- matrix(c(1, c, c, 1), 2, 2) testdata <- mvrnorm(n=n, rep(0, 2), Sigma) return(list(testdata[,1], testdata[,2])) } number_of_top100_genes <- function(experiment) { sum(which(rank(experiment[[1]]) < 100) %in% which(rank(experiment[[2]]) < 100)) } cat("c) How many of the top 100 genes from the original experiment would you expect in the top 100 of the repeated experiment?\n\n ", mean(replicate(50, number_of_top100_genes(generate_testdata(5000)))), "\n\n") cat("d) If we had used an array with 30000 genes. How many of the top 100 genes from the original experiment\n", " would you expect in the top 100 of the repeated experiment?\n\n ", mean(replicate(50, number_of_top100_genes(generate_testdata(30000)))), "\n\n")