Hello i have a table like this :
chr start end con_1_1 con_1_2 con_1_3 con_2_1 con_2_2 con_2_3
1 1 7512 0.45180723 0.21982759 0.06666667 0.4105960 0.1024735 0.2284710
1 13169 20070 0.07142857 0.77631579 0.90434783 0.1363636 0.8985507 0.6033058
1 36598 37518 0.13750000 0.43300248 0.09113300 0.9612403 0.1233596 0.7459016
1 37512 40365 0.64940239 0.95954693 0.46091644 0.7251656 0.1325648 0.4121901
1 40359 48801 0.09504132 0.96491228 0.15428571 0.6388889 0.5165165 0.8050847
1 77084 83129 0.91773779 0.28978224 0.56115108 0.9587302 0.5469256 0.6995614
1 83123 87907 0.86226415 0.05175159 0.93600000 0.8953975 0.5000000 0.8991597
1 87901 90973 0.08943089 0.08850365 0.60000000 0.3804809 0.8990385 0.9858824
1 101231 108778 0.11898734 0.40900735 0.08300781 0.7094156 0.4553571 0.2787356
1 108792 109423 0.12676056 0.24483776 0.56803456 0.4175824 0.3546196 0.5549451
My data are in 2 conditions with 3 replications in each condition. I would like for each row to run a Kruskal-Wallis rank sum test.Which means that in each row the con1 ( with 3 values ) will be tested with con2 ( with 3 values ). Ath the end i will have a final table with chr start end and one column with the result of the test for each row.
This is what i tried but its very slow.
newdata <- read.csv("table.txt",header = T, sep="\t")
len <- nrow(newdata)
for (j in 1:len) {
data=newdata[len,]
flabel<-factor(c(rep("con1",3),rep("con2",3)))
data1=c(data[,4],data[,5],data[,6],data[,7],data[,8],data[,9])
datav=data.frame(flabel,data1)
test=kruskal.test(data1 ~ flabel, data = datav)
print(test$p.value)
}
Any suggestion or help to run the Kruskal-Wallis for each row in a faster way ?
Thank you
are all "con_1_1" reads from the same "individual" "replicate" or what ever, are they differant fragments of the same thing/ chromosome/ etc?