Last active
July 30, 2024 22:36
-
-
Save yannabraham/c1f9de9b23fb94105ca5 to your computer and use it in GitHub Desktop.
A quick way to create FCS files from CSV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(Biobase) | |
library(flowCore) | |
library(flowViz) | |
# simply replace the dummy dta below with your CSV data | |
dta <- matrix(rnorm(10000),ncol=10) | |
dimnames(dta)[[2]] <- LETTERS[1:10] | |
head(dta) | |
# you need to prepare some metadata | |
meta <- data.frame(name=dimnames(dta)[[2]], | |
desc=paste('this is column',dimnames(dta)[[2]],'from your CSV') | |
) | |
meta$range <- apply(apply(dta,2,range),2,diff) | |
meta$minRange <- apply(dta,2,min) | |
meta$maxRange <- apply(dta,2,max) | |
head(meta) | |
# all these are required for the following steps to work | |
# a flowFrame is the internal representation of a FCS file | |
ff <- new("flowFrame", | |
exprs=dta, | |
parameters=AnnotatedDataFrame(meta) | |
) | |
# a simple plot to check that it worked | |
xyplot(A~B,ff) | |
# now you can save it back to the filesystem | |
write.FCS(ff,paste(tempfile(),'FCS',sep='.')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
thanks for this script. How do I do step#5? replace dta with my own csv? thanks.