1 | # Set the wd:
|
---|
2 | setwd("C:/BASE/Illumina imports/BeadStudio output")
|
---|
3 |
|
---|
4 | # Choose the file:
|
---|
5 | filename <- "gene_profile.csv"
|
---|
6 |
|
---|
7 | #Set the number of arrays per chip:
|
---|
8 | arraysPerChip = 8; # 6
|
---|
9 | columnsPerArray = 8;
|
---|
10 |
|
---|
11 | # assign the column headers:
|
---|
12 | headerColumnNames <-c("MIN_Signal","AVG_Signal","MAX_Signal","NARRAYS","ARRAY_STDEV","BEAD_STDEV","Avg_NBEADS","Detection"
|
---|
13 |
|
---|
14 | illumina <- read.csv(file=paste(getwd(),"/",filename,sep=""),skip=7,header=TRUE,row.name=1)
|
---|
15 |
|
---|
16 | ncol(illumina)
|
---|
17 | nrow(illumina)
|
---|
18 |
|
---|
19 | numData = ncol(illumina) -
|
---|
20 | numArrays = numData / columnsPerArray # 8 data columns per array
|
---|
21 | numChips = numArrays/arraysPerChip #
|
---|
22 |
|
---|
23 | numChips
|
---|
24 |
|
---|
25 | if numChips%%1 ~= 0
|
---|
26 | "ERROR: an incomplete chip is in this file!"
|
---|
27 |
|
---|
28 | colnames(illumina) -> myCols
|
---|
29 |
|
---|
30 | # Derive the Chip names from the colnames:
|
---|
31 | # Format of first entry: "MIN_Signal.XXXXXXXXXX_A" ( 10 Xs: maybe different?)
|
---|
32 |
|
---|
33 | lenFirstData <-nchar(headerColumnNames[1])
|
---|
34 |
|
---|
35 | chipNums = NULL
|
---|
36 | arrayNames = NULL
|
---|
37 |
|
---|
38 | # Derive names of arrays:
|
---|
39 | for (k in 1:numChips){
|
---|
40 |
|
---|
41 | # Get the numbers of the chips:
|
---|
42 | colNum = 1 + (k-1)* (arraysPerChip *columnsPerArray)
|
---|
43 | chipNums = c(chipNums, substr(myCols [colNum],lenFirstData+2,nchar(myCols[colNum])-2))
|
---|
44 |
|
---|
45 | # Get names of all the arrays
|
---|
46 | labels = c("A","B","C","D","E","F","G","H")
|
---|
47 | labels = labels[1: arraysPerChip]
|
---|
48 | arrayNames = c(arrayNames, paste(chipNums[k],labels,sep="_"))
|
---|
49 | }
|
---|
50 | chipNums
|
---|
51 | arrayNames
|
---|
52 |
|
---|
53 |
|
---|
54 | # output arrays (groups of columnsPerArray columns, plus gene names)
|
---|
55 | for (k in 1:length(arrayNames))
|
---|
56 | {
|
---|
57 | outputCols <- c(1: columnsPerArray) + columnsPerArray * (k-1)
|
---|
58 | outputData <- illumina[,outputCols]
|
---|
59 | outputData <- cbind(rownames(illumina),outputData)
|
---|
60 |
|
---|
61 | colnames(outputData) <- as.character(c("TargetID",headerColumnNames))
|
---|
62 |
|
---|
63 | write.table(outputData,file = paste(arrayNames[k],".txt",sep=""),sep = "\t",row.names=FALSE,na="")
|
---|
64 | }
|
---|