Skip to content

Instantly share code, notes, and snippets.

@yannabraham
Last active July 30, 2024 22:36
Show Gist options
  • Save yannabraham/c1f9de9b23fb94105ca5 to your computer and use it in GitHub Desktop.
Save yannabraham/c1f9de9b23fb94105ca5 to your computer and use it in GitHub Desktop.

Revisions

  1. yannabraham revised this gist Sep 23, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion createFlowFrame.R
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ 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')
    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)
  2. yannabraham created this gist Sep 23, 2015.
    32 changes: 32 additions & 0 deletions createFlowFrame.R
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    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='.'))