-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathAria2csv.R
More file actions
24 lines (21 loc) · 1.72 KB
/
Aria2csv.R
File metadata and controls
24 lines (21 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#Christopher Hall, Wellcome Sanger Institute, [email protected]
#Bulk export of ARIA index information V3. Now with added flowsetieness and 384 well plate support
#load the required packages from BioConductor
source("https://bioconductor.org/biocLite.R")
biocLite("flowCore")
library(flowCore)
#Change setwd to the directory of your folder
setwd("C:/Users/ch15/Desktop/files")
#run these lines and csv files will be produced using the included compensation matrix for each file
files <- list.files(path=".", pattern=".fcs$") #list files in directory the $ means it must end with .fcs
fs<-read.flowSet(files, transformation = FALSE) #puts all the .fcs files into a flowset
fsApply(fs,function(frame){ #loop through the flowset
comp <- keyword(frame)$SPILL #take the compensation matrix, remove 16+17 for uncompensated data
new_frame <- compensate(frame,comp) #apply the comepensation matrix
editme<- data.frame(getIndexSort(new_frame)) #get the index data and convert to a data.frame to help with the WellID (new_frame -> frame if not compensating)
editme$XLoc<-chartr("0", "A", editme$XLoc) #replace '0' with 'A' because setNames seems to not work with 0 with a really odd error
editme$WellID<-setNames(c("A","B","C","D","E","F","G","H","I","J","K","L","M","N","N","P"), c("A","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"))[editme$XLoc] #use setNames to rename the XLoc positions with well names
editme$XLoc<-chartr("A", "0", editme$XLoc) # #restore original XLoc '0' name
editme$WellID<-paste(editme$WellID,editme$YLoc +1, sep="") #add one to each YLoc to match the plate designations
write.csv(editme, file=paste(keyword(new_frame,"GUID"), "_index.csv", sep="")) #write a csv using the GUID keyword as the filename
})