Expand description
FCS File Manipulation Operations
This module provides a comprehensive set of tools for manipulating and analyzing Flow Cytometry Standard (FCS) files.
It includes methods for reading FCS files, extracting metadata, and processing data segments.
§Overview
The Flow Cytometry Standard (FCS) is a file format used to store data generated by flow cytometry experiments. This library allows users to easily read and manipulate FCS files in Rust. Key features include:
- File Handling: Open and read FCS files in a structured and efficient manner.
- Metadata Extraction: Extract and validate metadata from FCS files, ensuring all required information is available.
- Data Processing: Parse data segments from FCS files and convert them into usable formats such as dataframes.
- Data Transformation: Can transform raw data using arcsinh.
- Error Handling: Comprehensive error handling to deal with various issues that may arise during file operations.
§Getting Started
To get started with this library, you need to add it as a dependency in your Cargo.toml
:
[dependencies]
fcs_rs = "0.1.0"
Then, include the library in your project:
use fcs_rs::{
FcsFile,
FlowSample,
FcsError
};
§Examples
§Opening an FCS File
use fcs_rs::FcsFile;
let fcs_file = FcsFile::open("path/to/file.fcs")?;
§Reading an FCS File
use fcs_rs::{FcsFile, FcsError};
let fcs_file = FcsFile::open("path/to/file.fcs")?;
let flow_sample = fcs_file.read()?;
println!("{:?}", flow_sample.data);
println!("{:?}", flow_sample.parameters);
§Extracting Column Names
use fcs_rs::FcsFile;
let fcs_file = FcsFile::open("path/to/file.fcs")?;
let flow_sample = fcs_file.read()?;
let column_names = flow_sample.get_dataframe_columns();
println!("{:?}", column_names);
§Applying Arcsinh Transformation
use fcs_rs::FcsFile;
let fcs_file = FcsFile::open("path/to/file.fcs")?;
let mut flow_sample = fcs_file.read()?;
let column_names = flow_sample.get_dataframe_columns();
flow_sample.arcsinh_transform(5.0, &column_names)?;
println!("{:?}", flow_sample.data);
§Creating a DataFrame
use fcs_rs::data::create_dataframe;
use polars::prelude::*;
let column_titles = vec!["FSC-W".to_string(), "FITC-A".to_string()];
let data = vec![vec![1.0, 2.0, 3.0], vec![4.0, 5.0, 6.0]];
let df = create_dataframe(&column_titles, &data)?;
println!("{:?}", df);
§Modules
- data: Contains structures and functions for handling the data segments of FCS files, including parsing and transformation operations.
- header: Includes methods for reading and validating the header segments of FCS files.
- text: Provides functions for reading and validating the text segments of FCS files.
§Constants
- VALID_FCS_VERSIONS: A list of supported FCS versions.
- REQUIRED_KEYWORDS: A list of required non-parameter indexed keywords for the FCS text segment.
§Error Handling
The FcsError
enum defines various errors that can occur while processing FCS files, including I/O errors,
invalid headers, unsupported versions, metadata issues, missing required keywords, and invalid data segments.
Re-exports§
pub use crate::header::read_header;
pub use crate::text::read_metadata;
pub use crate::text::validate_text;
pub use crate::data::FlowSample;
pub use crate::data::parse_data;
pub use crate::data::read_events;
pub use crate::data::create_dataframe;
Modules§
Structs§
- FcsFile
- An object providing access to an FCS file.
Enums§
- FcsError
- Represents errors that can occur while processing FCS (Flow Cytometry Standard) files.
Constants§
- REQUIRED_
KEYWORDS - Required non-parameter indexed keywords for FCS text segment
- VALID_
FCS_ VERSIONS