This is a document describing new functionality, bug fixes, breaking changes, etc. associated with Selene version releases from v0.5.0 onwards.
config_utils.py
: Add additional information saved upon running Selene. Specifically, we now save the version of Selene that the latest run used, make a copy of the input configuration file, and save this along with the model architecture file in the output directory. This adds a new dependency to Selene, the packageruamel.yaml
H5Dataloader
and_H5Dataset
: PreviouslyH5Dataloader
had a number of arguments that were used to then initialize_H5Dataset
internally. One major change in this version is that we now ask that users initialize_H5Dataset
explicitly and then pass it toH5Dataloader
as a class argument. This makes the two classes consistent with the PyTorch specifications forDataset
andDataLoader
classes, enabling them to be compatible with different data parallelization configurations supported by PyTorch and the PyTorch Lightning framework._H5Dataset
class initialization optional arguments:unpackbits
can now be specified separately for sequences and targets by way ofunpackbits_seq
andunpackbits_tgt
use_seq_len
enables subsetting to the centeruse_seq_len
length of the sequences in the dataset.shift
(particularly paired withuse_seq_len
) allows for retrieving sequences shifted from the center position byshift
bases. Note currentlyshift
only allows shifting in one direction, depending on whether you pass in a positive or negative integer.
GenomicFeaturesH5
: This is a new targets class to handle continuous-valued targets, stored in an HDF5 file, that can be retrieved based on genomic coordinate. Once again, genomic regions are stored in a tabix-indexed .bed file, with the main change being that the BED file now specifies for each genomic regions the index of the row in the HDF5 matrix that contains all the target values to predict. If multiple target rows are returned for a query region, the average of those rows is returned.RandomPositionsSampler
:exclude_chrs
: Added a new optional argument which by default excludes all nonstandard chromosomesexclude_chrs=['_']
by ignoring all chromosomes with an underscore in the name. Pass in a list of chromosomes or substrings to exclude. When loading possible sampling positions, the class now iterates through theexclude_chrs
list and checks for each substrings
in list ifs in chrom
, and if so, skips that chromosome entirely.- Internal function
_retrieve
now takes in an optional argumentstrand
(defaultNone
) to enable explicit retrieval of a sequence atchrom, position
for a specific side. The default behavior of theRandomPositionsSampler
class remains the same, with the strand side randomly selected for each genomic position sampled.
PerformanceMetrics
:- Now supports
spearmanr
andpearsonr
fromscipy.stats
. Room for improvement to generalize this class in the future. - The
update
function now has an optional argumentscores
which can pass in a subset of the metrics aslist(str)
to compute.
- Now supports
TrainModel
:self.step
starts fromself._start_step
, which is non-zero if loaded from a Selene-saved checkpoint- removed call to
self._test_metrics.visualize
inevaluate
since the visualize method does not generalize well.
NonStrandSpecific
: Can now handle a model outputting two outputs inforward
, will handle by taking either the mean or max of each of the two individual outputs for their forward and reverse predictions. A customNonStrandSpecific
class is recommended for more specific cases.
- Adjust dependency requirements
- Fix Cython type error causing build issues with Python 3.9+
- PyTorch<=1.9 compatibility
sampler.MultiSampler
:MultiSampler
accepts any Selene sampler for each of the train, validation, and test partitions where previouslyMultiFileSampler
only acceptedFileSampler
s. We will deprecateMultiFileSampler
in our next major release.DataLoader
: Parallel data loading based on PyTorch'sDataLoader
class, which can be used with Selene'sMultiSampler
andMultiFileSampler
class. (see:sampler.SamplerDataLoader
,sampler.H5DataLoader
)- To support parallelism via multiprocessing, the sampler that
SamplerDataLoader
used needs to be picklable. To enable this, opening file operations are delayed to when any method that needs the file is called. There is no change to the API and settinginit_unpicklable=True
in__init__
forGenome
and allOnlineSampler
classes will fully reproduce the functionality inselene_sdk<=0.4.8
. sampler.RandomPositionsSampler
: added support forcenter_bin_to_predict
taking in a list/tuple of two integers to specify the region from which to query the targets---that is,center_bin_to_predict
by default (center_bin_to_predict=<int>
) queries targets based on the center bin size, but can be specified as start and end integers that are not at the center if desired.EvaluateModel
: accepts a list of metrics (by default computing ROC AUC and average precision) with which to evaluate the test dataset.
- Command-line interface (CLI): You can now run the CLI directly with
python -m selene_sdk
(if you have cloned the repository, make sure you have locally installedselene_sdk
viapython setup.py install
, orselene_sdk
is in the same directory as your script / added toPYTHONPATH
). Developers can make a copy of theselene_sdk/cli.py
script and use it the same way thatselene_cli.py
was used in earlier versions of Selene (python -u cli.py <config-yml> [--lr]
)
EvaluateModel
:use_features_ord
allows you to evaluate a trained model on only a subset of chromatin features (targets) predicted by the model. If you are using aFileSampler
for your test dataset, you now have the option to pass in a subsetted matrix; however, this matrix must be ordered the same way asfeatures
(the original targets prediction ordering) and not in the same ordering asuse_features_ord
. However, the final model predictions and targets (test_predictions.npz
andtest_targets.npz
) will be outputted according to theuse_features_ord
list and ordering.MatFileSampler
: Previously theMatFileSampler
reset the pointer to the start of the matrix too early (going back to the first sample before we had finished sampling the whole matrix).- CLI learning rate: Edge cases (e.g. not specifying the learning rate via CLI or config) previously were not handled correctly and did not throw an informative error.