Skip to content

Fix README examples for the Polars DataFrame read_gtf returns - #74

Closed
iskandr wants to merge 1 commit into
masterfrom
deslop/readme-examples
Closed

iskandr wants to merge 1 commit into
masterfrom
deslop/readme-examples

Conversation

@iskandr

@iskandr iskandr commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by #93 and #95, which document the current pandas-default API and retain working gene and transcript examples. Both refreshed branches pass all 213 tests and their documentation builds.

The Polars-default change below describes the older 2.x API.


Both README examples fail with the current read_gtf.

  • Example 1. read_gtf returns a Polars DataFrame by default (result_type="polars", gtfparse/read_gtf.py:274). The pandas-style df[df["feature"] == "gene"] raises ValueError: expected 20 values when selecting columns by boolean mask. Changed to df.filter(polars.col(...) == ...), with a note about result_type="pandas".
  • Example 2. The dict was keyed by df["seqname"] (the chromosome) and kept only feature == "gene" rows. StringTie GTFs have only transcript and exon rows (see tests/data/B16.stringtie.head.gtf), so the result was always {}. Changed to transcript FPKMs keyed by transcript_id.
  • Added a one-line gene_id lookup, which is what Example of how to find a feature by gene_id or transcript_id #13 asked for.

I ran both snippets against tests/data/ensembl_grch37.head.gtf and tests/data/B16.stringtie.head.gtf with polars 1.43. Patch version bumped to 2.8.1 per AGENTS.md.

Closes #13

https://claude.ai/code/session_01DctgBZ5rJiuNzpWXqrNguT

read_gtf returns a Polars DataFrame by default, so the pandas-style
boolean-mask indexing in the first example raises ValueError. The
StringTie example keyed its dict by seqname and filtered on "gene"
features, which StringTie GTFs don't contain, so it always produced an
empty dict. Use DataFrame.filter, key transcript FPKMs by transcript_id,
note result_type="pandas", and show a gene_id lookup.

Closes #13

Claude-Session: https://claude.ai/code/session_01DctgBZ5rJiuNzpWXqrNguT
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 34867758590

Coverage remained the same at 95.618%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 251
Covered Lines: 240
Line Coverage: 95.62%
Coverage Strength: 0.96 hits per line

💛 - Coveralls

@iskandr iskandr closed this Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Example of how to find a feature by gene_id or transcript_id

2 participants