Skip to content

Commit

Permalink
removed bulk/sc subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
mlbendall committed Feb 22, 2023
1 parent 1a37165 commit 3131e78
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 143 deletions.
79 changes: 74 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Changelog
# Version History

All notable changes to this project will be documented in this file.

Expand All @@ -14,12 +14,81 @@ All notable changes to this project will be documented in this file.

### Changed
- Depends on python >= 3.7, ensure dict objects maintain insertion-order.
See [What’s New In Python 3.7](https://docs.python.org/3/whatsnew/3.7.html)

See [What’s New In Python 3.7](https://docs.python.org/3/whatsnew/3.7.html)
- Removed `bulk` and `sc` subcommands since the single-cell
[stellarscope](https://github.com/nixonlab/stellarscope) project has moved
into its own repository.

### Fixed

_The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)._


## Previous versions

Prior to this CHANGELOG, changes were tracked in [README.md](./README.md).
The previous version history is relocated here:

### v1.0.3.1

+ Checks that GTF feature type is "exon"
+ Skips GTF lines missing attribute (with warning)

### v1.0.3
+ Added cimport statements to calignment.pyx (MacOS bug fix)
+ Fixed warning about deprecated PyYAML yaml.load
+ Compatibility with intervaltree v3.0.2

### v1.0.2
+ Temporary files are written as BAM

### v1.0.1
+ Changed default `theta_prior` to 200,000

### v1.0
+ Removed dependency on `git`
+ Release version

### v0.6.5
+ Support for sorted BAM files
+ Parallel reading of sorted BAM files
+ Improved performance of EM
+ Improved memory-efficiency of spare matrix

#### v0.5.4.1
+ Fixed bug where random seed is out of range

#### v0.5.4
+ Added MIT license
+ Changes to logging/reporting

#### v0.5.3
+ Improvements to `telescope resume`

#### v0.5.2
+ Implemented checkpoint and `telescope resume`

#### v0.5.1
+ Refactoring Telescope class with TelescopeLikelihood
+ Improved memory usage

#### v0.4.2
+ Subcommand option parsing class
+ Cython for alignment parsing
+ HTSeq as alternate alignment parser

#### v0.3.2
+ Python3 compatibility

#### v0.3
+ Implemented IntervalTree for Annotation data structure
+ Added support for annotation files where a locus may be non-contiguous.
+ Overlapping annotations with the same key value (locus) are merged
+ User can set minimum overlap criteria for assigning read to locus, default = 0.1

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
#### v0.2

+ Implemented checkpointing
+ Output tables as pickled objects
+ Changes to report format and output
104 changes: 18 additions & 86 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,16 @@ Telescope [![install with bioconda](https://img.shields.io/badge/install%20with-

* [Installation](#installation)
* [Usage](#usage)
* [`telescope sc assign`](#telescope-assign)
* [`telescope sc resume`](#telescope-resume)
* [`telescope bulk assign`](#telescope-assign)
* [`telescope bulk resume`](#telescope-resume)
* [`telescope assign`](#telescope-assign)
* [`telescope resume`](#telescope-resume)
* [Output](#Output)
* [Telescope report](#telescope-report)
* [Updated SAM file](#updated-sam-file)
* [Version History](#version-history)

## Installation

**Recommended:**
**Stable version:**

Install Telescope using [bioconda](https://bioconda.github.io):

Expand All @@ -37,38 +35,36 @@ See [Getting Started](https://bioconda.github.io/user/install.html) for
instructions on setting up bioconda.


**Alternative:**
**Latest version:**

Use conda package manager to install dependencies, then
Use conda/mamba package manager to install dependencies, then
use `pip` to install Telescope.

The following has been testing using miniconda3 on macOS and Linux (CentOS 7):

```bash
conda create -n telescope_env python=3.6 future pyyaml cython=0.29.7 \
numpy=1.16.3 pandas=1.1.3 scipy=1.2.1 pysam=0.15.2 htslib=1.9 intervaltree=3.0.2

conda activate telescope_env
pip install git+git://github.com/mlbendall/telescope.git
telescope assign -h
mamba env create -n telescope https://github.com/mlbendall/telescope/raw/main/environment.yml
conda activate telescope
pip install git+https://github.com/mlbendall/telescope.git
telescope --version
```

## Testing

A BAM file (`alignment.bam`) and annotation (`annotation.gtf`) are included in
the telescope package for testing. The files are installed in the `data`
directory of the package root. We've included a subcommand, `telescope [sc/bulk] test`,
directory of the package root. We've included a subcommand, `telescope test`,
to generate an example command line with the correct paths.
For example, to generate an example command line for the bulk RNA-seq workflow:
For example, to generate an example command line:

```
telescope bulk test
telescope test
```

The command can be executed using `eval`:

```
eval $(telescope bulk test)
eval $(telescope test)
```

The expected output to STDOUT includes the final log-likelihood, which was
Expand All @@ -79,9 +75,9 @@ platform-dependent due to differences in floating point precision.

## Usage

### `telescope [sc/bulk] assign`
### `telescope assign`

The `telescope [sc/bulk] assign` program finds overlapping reads between an alignment
The `telescope assign` program finds overlapping reads between an alignment
(SAM/BAM) and an annotation (GTF) then reassigns reads using a statistical
model. This algorithm enables locus-specific quantification of transposable
element expression.
Expand Down Expand Up @@ -209,9 +205,9 @@ Model Parameters:
```


### `telescope [sc/bulk] resume`
### `telescope resume`

The `telescope [sc/bulk] resume` program loads the checkpoint from a previous run and
The `telescope resume` program loads the checkpoint from a previous run and
reassigns reads using a statistical model.

#### Basic usage
Expand All @@ -226,7 +222,7 @@ telescope sc resume [checkpoint]
#### Advanced usage

Options are available for tuning the EM optimization, similar to
`telescope [sc/bulk] assign`.
`telescope assign`.

```
Input Options:
Expand Down Expand Up @@ -341,67 +337,3 @@ UCSC sanctioned tag, see documentation
[here.](http://genome.ucsc.edu/goldenpath/help/hgBamTrackHelp.html)
+ `XP:Z` Alignment probability - estimated posterior probability for this alignment.

## Version History

### v1.0.3.1

+ Checks that GTF feature type is "exon"
+ Skips GTF lines missing attribute (with warning)

### v1.0.3
+ Added cimport statements to calignment.pyx (MacOS bug fix)
+ Fixed warning about deprecated PyYAML yaml.load
+ Compatibility with intervaltree v3.0.2

### v1.0.2
+ Temporary files are written as BAM

### v1.0.1
+ Changed default `theta_prior` to 200,000

### v1.0
+ Removed dependency on `git`
+ Release version

### v0.6.5
+ Support for sorted BAM files
+ Parallel reading of sorted BAM files
+ Improved performance of EM
+ Improved memory-efficiency of spare matrix

#### v0.5.4.1
+ Fixed bug where random seed is out of range

#### v0.5.4
+ Added MIT license
+ Changes to logging/reporting

#### v0.5.3
+ Improvements to `telescope resume`

#### v0.5.2
+ Implemented checkpoint and `telescope resume`

#### v0.5.1
+ Refactoring Telescope class with TelescopeLikelihood
+ Improved memory usage

#### v0.4.2
+ Subcommand option parsing class
+ Cython for alignment parsing
+ HTSeq as alternate alignment parser

#### v0.3.2
+ Python3 compatibility

#### v0.3
+ Implemented IntervalTree for Annotation data structure
+ Added support for annotation files where a locus may be non-contiguous.
+ Overlapping annotations with the same key value (locus) are merged
+ User can set minimum overlap criteria for assigning read to locus, default = 0.1

#### v0.2

+ Implemented checkpointing
+ Output tables as pickled objects
+ Changes to report format and output
65 changes: 13 additions & 52 deletions telescope/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
test Generate a command line for testing
'''

def generate_test_command(args, seq_mode):
def generate_test_command(args):
try:
_ = FileNotFoundError()
except NameError:
Expand All @@ -46,7 +46,7 @@ class FileNotFoundError(OSError):
raise FileNotFoundError(
errno.ENOENT, os.strerror(errno.ENOENT), _gtfpath
)
print('telescope %s assign %s %s' % (seq_mode, _alnpath, _gtfpath), file=sys.stdout)
print('telescope assign %s %s' % (_alnpath, _gtfpath), file=sys.stdout)

def main():
if len(sys.argv) == 1:
Expand All @@ -66,68 +66,29 @@ def main():
default=VERSION,
)

subparsers = parser.add_subparsers(help='Sequencing modality help', dest = 'sc_or_bulk')

''' Parser for scRNA-seq '''
sc_parser = subparsers.add_parser('sc',
description='''Telescope for single-cell RNA-sequencing data sets''',
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)

''' Parser for bulk RNA-seq '''
bulk_parser = subparsers.add_parser('bulk',
description='''Telescope for bulk RNA-sequencing data sets''',
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)

sc_subparser = sc_parser.add_subparsers(help='scRNA-seq sub-command help', dest = 'subcommand')

''' Parser for scRNA-seq assign '''
sc_assign_parser = sc_subparser.add_parser('assign',
description='''Reassign ambiguous fragments that map to repetitive
elements (scRNA-seq)''',
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
telescope_assign.scIDOptions.add_arguments(sc_assign_parser)
sc_assign_parser.set_defaults(func=lambda args: telescope_assign.run(args, sc = True))

''' Parser for scRNA-seq resume '''
sc_resume_parser = sc_subparser.add_parser('resume',
description='''Resume a previous telescope run (scRNA-seq)''',
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
telescope_resume.scResumeOptions.add_arguments(sc_resume_parser)
sc_resume_parser.set_defaults(func=lambda args: telescope_resume.run(args, sc = True))

sc_test_parser = sc_subparser.add_parser('test',
description='''Print a test command''',
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
sc_test_parser.set_defaults(func=lambda args: generate_test_command(args, 'sc'))

bulk_subparser = bulk_parser.add_subparsers(help='Bulk RNA-seq sub-command help', dest='subcommand')
subparser = parser.add_subparsers(help='Bulk RNA-seq sub-command help', dest='subcommand')

''' Parser for bulk RNA-seq assign '''
bulk_assign_parser = bulk_subparser.add_parser('assign',
description='''Reassign ambiguous fragments that map to repetitive elements (bulk RNA-seq)''',
assign_parser = subparser.add_parser('assign',
description='''Reassign ambiguous fragments that map to repetitive elements''',
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
telescope_assign.BulkIDOptions.add_arguments(bulk_assign_parser)
bulk_assign_parser.set_defaults(func=lambda args: telescope_assign.run(args, sc = False))
telescope_assign.BulkIDOptions.add_arguments(assign_parser)
assign_parser.set_defaults(func=lambda args: telescope_assign.run(args, sc = False))

''' Parser for bulk RNA-seq resume '''
bulk_resume_parser = bulk_subparser.add_parser('resume',
description='''Resume a previous telescope run (scRNA-seq)''',
resume_parser = subparser.add_parser('resume',
description='''Resume a previous telescope run''',
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
telescope_resume.BulkResumeOptions.add_arguments(bulk_resume_parser)
bulk_resume_parser.set_defaults(func=lambda args: telescope_resume.run(args, sc = False))
telescope_resume.BulkResumeOptions.add_arguments(resume_parser)
resume_parser.set_defaults(func=lambda args: telescope_resume.run(args, sc = False))

bulk_test_parser = bulk_subparser.add_parser('test',
test_parser = subparser.add_parser('test',
description='''Print a test command''',
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
bulk_test_parser.set_defaults(func=lambda args: generate_test_command(args, 'bulk'))
test_parser.set_defaults(func=lambda args: generate_test_command(args))

args = parser.parse_args()
args.func(args)
Expand Down

0 comments on commit 3131e78

Please sign in to comment.