Releases: genecell/COSG
COSG v1.0.4 Release Notes
Highlights
This release includes performance improvements, a new visualization function plotMarkerStream, and enhanced input validation for a more robust user experience.
🐛 Bug Fixes
cosg.py
-
Fixed
use_rawparameter bug: Previously, theuse_rawparameter was non-functional because a second assignment always overwrote the first. Nowuse_raw=Truecorrectly usesadata.raw.Xwhen available. -
Fixed DataFrame fragmentation warning: Resolved the performance issue caused by repeated
pd.concat()in loop. Results are now pre-allocated in dictionaries and the DataFrame is built once after the loop, eliminating the "DataFrame is highly fragmented" warning for datasets with many clusters. -
Blocked unsupported parameter combination: Using
batch_keywith a subset ofgroupsnow raises a clearNotImplementedErrorinstead of producing incorrect results silently.
_plotting.py
- Fixed
AttributeErrorin palette filtering: Addedhasattr()check before accessing.cat.categoriesto handle non-categorical columns gracefully.
✨ New Features
New Parameter: expressed_min_num_cells_in_target_group
Added a new parameter to prevent overly permissive expression thresholds in small clusters when remove_lowly_expressed=True.
cosg.cosg(
adata,
groupby='cell_type',
remove_lowly_expressed=True,
expressed_pct=0.1,
expressed_min_num_cells_in_target_group=3 # NEW: minimum absolute threshold
)The actual threshold is now: max(n_cells * expressed_pct, expressed_min_num_cells_in_target_group)
For example, a cluster with 10 cells and expressed_pct=0.1 will use a threshold of max(1, 3) = 3 cells instead of just 1 cell.
New Visualization: plotMarkerStream
Added a new streamgraph visualization function for displaying marker gene specificity scores across cell types.
cosg.plotMarkerStream(
adata,
groupby='cell_type',
n_top_genes=3,
plot_type='stacked', # Options: 'proportional', 'stacked', 'mirror', 'ridge'
orientation='vertical', # Options: 'vertical', 'horizontal'
show_brackets=True,
smooth=False
)Features include:
- Multiple plot types (proportional, stacked, mirror, ridge)
- Vertical or horizontal orientation
- Optional smoothing with multiple methods (gaussian, spline, savgol)
- Customizable cell type brackets and gene labels
- Flexible color schemes and legend positioning
🛡️ Input Validation
Added comprehensive input validation for all parameters in cosg():
groupbycolumn existence checkgroupsparameter validation (must be a sequence, not a single value)- Invalid group detection with helpful error messages
n_genes_user >= 1expressed_pctin range[0, 1]expressed_min_num_cells_in_target_group >= 1layerexistence validationbatch_keycolumn existence check- Delimiter collision detection in
indexByGene()
🔧 Code Quality Improvements
- Replaced
sys.exit(0)with properValueErrorexceptions - Added type hints to
plotMarkerDendrogram()andplotMarkerDotplot() - Stored additional parameters in
adata.uns[key_added]['params']for reproducibility
📦 Installation
pip install cosg --upgradeOr install from source:
pip install git+https://github.com/genecell/COSG.gitThank you to all users!
COSG v1.0.3
Release v1.0.3
🐛 Fixes
- Fixed the incompatibility with multiple index columns of
adata.uns['cosg']['COSG']inadata.writefunction
🚀 Improvements
- Enhanced
plotMarkerDendrogramfunction with several new capabilities:- Implemented support for customized pairs of cell type and gene list
- Added color control for nodes and edges
- Added cell type filtering functionality
- Integrated support for curved edges in visualization
v1.0.2 – improved marker visualization, normalized COSG scores, batch_key support, and fixes
Release v1.0.2
New Features
- Added
plotMarkerDotplotandplotMarkerDendrogramfor enhanced marker gene visualization. - Introduced support for
batch_keyto compute cosine similarities separately across different batches. - Enabled calculation of normalized COSG scores for comparing gene expression specificity across cell types or datasets.
Fixes & Improvements
- Resolved a SciPy version deprecation issue related to
.Aattribute usage. - Fixed a DataFrame manipulation warning.
- Added verbosity control, allowing users to adjust log output levels.
First release
First release for COSG