Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Pass parameters to read #44

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,4 @@ docs/conf.py
_docs_tmp*
*.fcs
*.h5ad
test.ipynb
35 changes: 24 additions & 11 deletions readfcs/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,21 +247,36 @@ def to_anndata(self, reindex=True) -> ad.AnnData:
for k, v in adata.var.dtypes.items():
if v == "object":
adata.var[k] = adata.var[k].astype("category")

return adata


def read(filepath, reindex=True) -> ad.AnnData:
def read(
filepath: str | Path,
reindex: bool = True,
ignore_offset_error: bool = False,
ignore_offset_discrepancy: bool = False,
use_header_offsets: bool = False,
) -> ad.AnnData:
"""Read in fcs file as AnnData.

Args:
filepath: str or Path
location of fcs file to parse
reindex: bool. Default is True
variables will be reindexed with marker names if possible otherwise channels
filepath: Location of fcs file to parse
reindex: Whether variables will be reindexed with marker names if possible otherwise channels
ignore_offset_error: Ignore data offset error.
ignore_offset_discrepancy: Ignore discrepancy between the HEADER and TEXT values for the DATA byte offset location.
use_header_offsets: Use the HEADER section for the data offset locations.
Setting this option to True also suppresses an error in cases of an offset discrepancy.

Returns:
an AnnData object
An AnnData object
"""
fcsfile = ReadFCS(filepath)
fcsfile = ReadFCS(
filepath,
ignore_offset_error=ignore_offset_error,
ignore_offset_discrepancy=ignore_offset_discrepancy,
use_header_offsets=use_header_offsets,
)
return fcsfile.to_anndata(reindex=reindex)


Expand All @@ -279,13 +294,10 @@ def view(
filepath: Location of fcs file to parse
data_set: Index of retrieved data set in the fcs file.
ignore_offset_error: Ignore data offset error.
Default is False
ignore_offset_discrepancy: Ignore discrepancy between the HEADER and TEXT values for the DATA byte offset location.
Default is False
use_header_offsets: Use the HEADER section for the data offset locations.
Default is False. Setting this option to True also suppresses an error in cases of an offset discrepancy.
Setting this option to True also suppresses an error in cases of an offset discrepancy.
only_text: Only read the “text” segment of the FCS file without loading event data.
Default is False

Returns:
a tuple of (data, metadata)
Expand All @@ -310,4 +322,5 @@ def view(

# meta
meta = flow_data.text

return meta, data
Loading