let's say I have a matrix like this
dat <- read.table(text = " code.1 code.2 code.3 code.4
1 82 93 NA NA
2 15 85 93 NA
3 93 89 NA NA
4 81 NA NA NA",
header = TRUE, stringsAsFactors = FALSE)
dat2=data.matrix(dat)
In reality my matrix has 132 columns and around 15000 rows. And my column names look like this: NoD_14569_norm.1 NoD_14569_norm.2 NoD_14569_norm.3 NoD_14581_30mM.1 NoD_14581_30mM.2 NoD_14581_30mM.3
What I want to do is create a 1000 random permutations of my column names where everything in the matrix would stay the same except there would be new order of column names.
The goal is to perform the following code on each of 1000 data frames
subject="all_replicate"
targets<-readTargets(paste(PhenotypeDir,"hg_sg_",subject,"_target.txt", sep=''))
Treat <- factor(targets$Treatment,levels=c("C","T"))
Replicates <- factor(targets$rep)
design <- model.matrix(~Replicates+Treat)
corfit <- duplicateCorrelation(dat2, block = targets$Subject)
corfit$consensus.correlation
fit <-lmFit(dat2,design,block=targets$Subject,correlation=corfit$consensus.correlation)
fit<-eBayes(fit)
y1=topTable(fit, coef="TreatT", n=nrow(genes),adjust.method="BH",genelist=genes)
Inside of y1 there is column names P.value containing p values and I would like to plot distribution of those for all above mentioned 1000 permutations of column names.
Please advise