Search code examples
pythonrcsvexport-to-csvfile-extension

how to convert lmd file to csv? [Flow Cytometry data]


lmd file extension is often used for generating flow cytometry data. But this couldn't be directly used for processing either in R or Python. Is there a way to somehow convert it to csv or some renowned format?


Solution

  • This is a bit tricky. So far I haven't come across any such direct conversion function. Perhaps, fcs is a more common format for flow-cytometry. Hence, we will first need to convert lmd to fcs and then to csv format.

    Step 1: lmd to fcs [Using R]

    # install
    source("http://bioconductor.org/biocLite.R")
    biocLite("flowCore")
    
    # convert
    library(tools) # for file_path_sans_ext
    
    if (!requireNamespace("BiocManager", quietly = TRUE))
      install.packages("BiocManager")
    
    BiocManager::install(version = '3.10')
    
    BiocManager::install("flowCore")
    library(flowCore)
    
    in.fname <- 'Filename.LMD'
    folder <- '/home/User/Desktop/Data/'
    x <- read.FCS(paste0(folder, in.fname))
    summary(x)
    out.fname <- paste0(file_path_sans_ext(in.fname), '.fcs')
    write.FCS(x, paste0(folder, out.fname))
    

    Note: Change User and Filename with your desired path and filename respectively Your fcs file will be saved in the same folder.

    Source: https://github.com/eyurtsev/FlowCytometryTools/issues/3

    Step 2: fcs to csv

    This could be done simply using the read.FCS() function to read in a FCS file, and then using write.delim() or write.csv() to create a .txt or .csv file.

    Source: https://www.bioconductor.org/packages/release/bioc/vignettes/flowCore/inst/doc/HowTo-flowCore.pdf