I have an R workflow that loads a folder of 24 .fcs files that have already been cleaned up and downsampled to 10,000 events into a formal class flowSet. The R script then transforms the @exprs matrix, runs flowSOM and UMAP on these data. These algorithms produce data frames that as 240,000 rows long (24 files x 10,000 events).
How do I get these three extra columns added to the 24 flowFrames within the flowSet?
Some of my code is below:
#Add data
path = "~/Desktop/Test"
files <- list.files(
path = path, pattern = "\\.fcs$", full.names = TRUE
)
d_flowSet <- read.flowSet(
files, transformation = FALSE, truncate_max_range = FALSE
)
setwd("~/Desktop/Test")
cols_lineage <- c(7,9:34)
#################
### Run UMAP ###
################
umap.out<-umap(somedata[cols_lineage])
head(umap.out)
plot.umap<-as.data.frame(umap.out$layout)
# Basic scatter plot of mpg according to cyl
plot(plot.umap,type="p",main="UMAP data", xlab='UMAP_X',ylab='UMAP_Y')
#################
### Export Data ###
################
cluster<-rowData(out_DA$d_se)
cluster<-cluster[,4]
UMAP_X<-umap.out$layout[,1]
UMAP_Y<-umap.out$layout[,2]
app.data<-as.matrix(cbind(cluster,UMAP_X,UMAP_Y))
How do I add this final app.data
to the original slowSet?
Thanks Mikheal, that worked a treat! I just had to play around with a
for
loop to get it working automatically. :)