code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def forward(self, x: Tensor, include_embeddings: bool = False): """ x : torch.Tensor, shape = (batch_size, n_mels, n_ctx) the mel spectrogram of the audio include_embeddings: bool whether to include intermediate steps in the output """ x = F.gelu(self.conv...
x : torch.Tensor, shape = (batch_size, n_mels, n_ctx) the mel spectrogram of the audio include_embeddings: bool whether to include intermediate steps in the output
forward
python
bytedance/LatentSync
latentsync/whisper/whisper/model.py
https://github.com/bytedance/LatentSync/blob/master/latentsync/whisper/whisper/model.py
Apache-2.0
def forward(self, x: Tensor, xa: Tensor, kv_cache: Optional[dict] = None, include_embeddings: bool = False): """ x : torch.LongTensor, shape = (batch_size, <= n_ctx) the text tokens xa : torch.Tensor, shape = (batch_size, n_mels, n_audio_ctx) the encoded audio features to...
x : torch.LongTensor, shape = (batch_size, <= n_ctx) the text tokens xa : torch.Tensor, shape = (batch_size, n_mels, n_audio_ctx) the encoded audio features to be attended on include_embeddings : bool Whether to include intermediate values in the output to th...
forward
python
bytedance/LatentSync
latentsync/whisper/whisper/model.py
https://github.com/bytedance/LatentSync/blob/master/latentsync/whisper/whisper/model.py
Apache-2.0
def install_kv_cache_hooks(self, cache: Optional[dict] = None): """ The `MultiHeadAttention` module optionally accepts `kv_cache` which stores the key and value tensors calculated for the previous positions. This method returns a dictionary that stores all caches, and the necessary hooks...
The `MultiHeadAttention` module optionally accepts `kv_cache` which stores the key and value tensors calculated for the previous positions. This method returns a dictionary that stores all caches, and the necessary hooks for the key and value projection modules that save the intermediat...
install_kv_cache_hooks
python
bytedance/LatentSync
latentsync/whisper/whisper/model.py
https://github.com/bytedance/LatentSync/blob/master/latentsync/whisper/whisper/model.py
Apache-2.0
def decode_with_timestamps(self, tokens) -> str: """ Timestamp tokens are above the special tokens' id range and are ignored by `decode()`. This method decodes given tokens with timestamps tokens annotated, e.g. "<|1.08|>". """ outputs = [[]] for token in tokens: ...
Timestamp tokens are above the special tokens' id range and are ignored by `decode()`. This method decodes given tokens with timestamps tokens annotated, e.g. "<|1.08|>".
decode_with_timestamps
python
bytedance/LatentSync
latentsync/whisper/whisper/tokenizer.py
https://github.com/bytedance/LatentSync/blob/master/latentsync/whisper/whisper/tokenizer.py
Apache-2.0
def language_token(self) -> int: """Returns the token id corresponding to the value of the `language` field""" if self.language is None: raise ValueError(f"This tokenizer does not have language token configured") additional_tokens = dict( zip( self.tokeni...
Returns the token id corresponding to the value of the `language` field
language_token
python
bytedance/LatentSync
latentsync/whisper/whisper/tokenizer.py
https://github.com/bytedance/LatentSync/blob/master/latentsync/whisper/whisper/tokenizer.py
Apache-2.0
def write_srt(transcript: Iterator[dict], file: TextIO): """ Write a transcript to a file in SRT format. Example usage: from pathlib import Path from whisper.utils import write_srt result = transcribe(model, audio_path, temperature=temperature, **args) # save SRT a...
Write a transcript to a file in SRT format. Example usage: from pathlib import Path from whisper.utils import write_srt result = transcribe(model, audio_path, temperature=temperature, **args) # save SRT audio_basename = Path(audio_path).stem with open(Path(out...
write_srt
python
bytedance/LatentSync
latentsync/whisper/whisper/utils.py
https://github.com/bytedance/LatentSync/blob/master/latentsync/whisper/whisper/utils.py
Apache-2.0
def load_model( name: str, device: Optional[Union[str, torch.device]] = None, download_root: str = None, in_memory: bool = False ) -> Whisper: """ Load a Whisper ASR model Parameters ---------- name : str one of the official model names listed by `whisper.available_models()`, or ...
Load a Whisper ASR model Parameters ---------- name : str one of the official model names listed by `whisper.available_models()`, or path to a model checkpoint containing the model dimensions and the model state_dict. device : Union[str, torch.device] the PyTorch device to ...
load_model
python
bytedance/LatentSync
latentsync/whisper/whisper/__init__.py
https://github.com/bytedance/LatentSync/blob/master/latentsync/whisper/whisper/__init__.py
Apache-2.0
def remove_symbols_and_diacritics(s: str, keep=""): """ Replace any other markers, symbols, and punctuations with a space, and drop any diacritics (category 'Mn' and some manual mappings) """ return "".join( c if c in keep else ADDITIONAL_DIACRITICS[c] if c in ADDITIO...
Replace any other markers, symbols, and punctuations with a space, and drop any diacritics (category 'Mn' and some manual mappings)
remove_symbols_and_diacritics
python
bytedance/LatentSync
latentsync/whisper/whisper/normalizers/basic.py
https://github.com/bytedance/LatentSync/blob/master/latentsync/whisper/whisper/normalizers/basic.py
Apache-2.0
def remove_symbols(s: str): """ Replace any other markers, symbols, punctuations with a space, keeping diacritics """ return "".join( " " if unicodedata.category(c)[0] in "MSP" else c for c in unicodedata.normalize("NFKC", s) )
Replace any other markers, symbols, punctuations with a space, keeping diacritics
remove_symbols
python
bytedance/LatentSync
latentsync/whisper/whisper/normalizers/basic.py
https://github.com/bytedance/LatentSync/blob/master/latentsync/whisper/whisper/normalizers/basic.py
Apache-2.0
def cpg(): """ >>> # +--------------+-----------+-----------+-----------+ >>> # | Chromosome | Start | End | CpG | >>> # | (category) | (int64) | (int64) | (int64) | >>> # |--------------+-----------+-----------+-----------| >>> # | chrX | 64181 | 64793 ...
>>> # +--------------+-----------+-----------+-----------+ >>> # | Chromosome | Start | End | CpG | >>> # | (category) | (int64) | (int64) | (int64) | >>> # |--------------+-----------+-----------+-----------| >>> # | chrX | 64181 | 64793 | 62 | ...
cpg
python
pyranges/pyranges
pyranges/data.py
https://github.com/pyranges/pyranges/blob/master/pyranges/data.py
MIT
def ucsc_bed(): """ >>> # +--------------+-----------+-----------+------------+------------+-----------------+--------------+---------------+-------------------+ >>> # | Chromosome | Start | End | Feature | gene_id | transcript_id | Strand | exon_number | transcript_name | ...
>>> # +--------------+-----------+-----------+------------+------------+-----------------+--------------+---------------+-------------------+ >>> # | Chromosome | Start | End | Feature | gene_id | transcript_id | Strand | exon_number | transcript_name | >>> # | (category) | ...
ucsc_bed
python
pyranges/pyranges
pyranges/data.py
https://github.com/pyranges/pyranges/blob/master/pyranges/data.py
MIT
def tss(self): """Return the transcription start sites. Returns the 5' for every interval with feature "transcript". See Also -------- pyranges.genomicfeatures.GenomicFeaturesMethods.tes : return the transcription end sites Examples -------- >>> gr = p...
Return the transcription start sites. Returns the 5' for every interval with feature "transcript". See Also -------- pyranges.genomicfeatures.GenomicFeaturesMethods.tes : return the transcription end sites Examples -------- >>> gr = pr.data.ensembl_gtf()[["Sou...
tss
python
pyranges/pyranges
pyranges/genomicfeatures.py
https://github.com/pyranges/pyranges/blob/master/pyranges/genomicfeatures.py
MIT
def tes(self, slack=0): """Return the transcription end sites. Returns the 3' for every interval with feature "transcript". See Also -------- pyranges.genomicfeatures.GenomicFeaturesMethods.tss : return the transcription start sites Examples -------- >...
Return the transcription end sites. Returns the 3' for every interval with feature "transcript". See Also -------- pyranges.genomicfeatures.GenomicFeaturesMethods.tss : return the transcription start sites Examples -------- >>> gr = pr.data.ensembl_gtf()[["Sou...
tes
python
pyranges/pyranges
pyranges/genomicfeatures.py
https://github.com/pyranges/pyranges/blob/master/pyranges/genomicfeatures.py
MIT
def introns(self, by="gene", nb_cpu=1): """Return the introns. Parameters ---------- by : str, {"gene", "transcript"}, default "gene" Whether to find introns per gene or transcript. nb_cpu: int, default 1 How many cpus to use. Can at most use 1 per chro...
Return the introns. Parameters ---------- by : str, {"gene", "transcript"}, default "gene" Whether to find introns per gene or transcript. nb_cpu: int, default 1 How many cpus to use. Can at most use 1 per chromosome or chromosome/strand tuple. Will...
introns
python
pyranges/pyranges
pyranges/genomicfeatures.py
https://github.com/pyranges/pyranges/blob/master/pyranges/genomicfeatures.py
MIT
def genome_bounds(gr, chromsizes, clip=False, only_right=False): """Remove or clip intervals outside of genome bounds. Parameters ---------- gr : PyRanges Input intervals chromsizes : dict or PyRanges or pyfaidx.Fasta Dict or PyRanges describing the lengths of the chromosomes. ...
Remove or clip intervals outside of genome bounds. Parameters ---------- gr : PyRanges Input intervals chromsizes : dict or PyRanges or pyfaidx.Fasta Dict or PyRanges describing the lengths of the chromosomes. pyfaidx.Fasta object is also accepted since it conveniently loads...
genome_bounds
python
pyranges/pyranges
pyranges/genomicfeatures.py
https://github.com/pyranges/pyranges/blob/master/pyranges/genomicfeatures.py
MIT
def tile_genome(genome, tile_size, tile_last=False): """Create a tiled genome. Parameters ---------- chromsizes : dict or PyRanges Dict or PyRanges describing the lengths of the chromosomes. tile_size : int Length of the tiles. tile_last : bool, default False Use gen...
Create a tiled genome. Parameters ---------- chromsizes : dict or PyRanges Dict or PyRanges describing the lengths of the chromosomes. tile_size : int Length of the tiles. tile_last : bool, default False Use genome length as end of last tile. See Also -------- ...
tile_genome
python
pyranges/pyranges
pyranges/genomicfeatures.py
https://github.com/pyranges/pyranges/blob/master/pyranges/genomicfeatures.py
MIT
def get_sequence(gr, path=None, pyfaidx_fasta=None): """Get the sequence of the intervals from a fasta file Parameters ---------- gr : PyRanges Coordinates. path : str Path to fasta file. It will be indexed using pyfaidx if an index is not found pyfaidx_fasta : pyfaidx.Fasta...
Get the sequence of the intervals from a fasta file Parameters ---------- gr : PyRanges Coordinates. path : str Path to fasta file. It will be indexed using pyfaidx if an index is not found pyfaidx_fasta : pyfaidx.Fasta Alternative method to provide fasta target, as a p...
get_sequence
python
pyranges/pyranges
pyranges/get_fasta.py
https://github.com/pyranges/pyranges/blob/master/pyranges/get_fasta.py
MIT
def get_transcript_sequence(gr, group_by, path=None, pyfaidx_fasta=None): """Get the sequence of mRNAs, e.g. joining intervals corresponding to exons of the same transcript Parameters ---------- gr : PyRanges Coordinates. group_by : str or list of str intervals are grouped by thi...
Get the sequence of mRNAs, e.g. joining intervals corresponding to exons of the same transcript Parameters ---------- gr : PyRanges Coordinates. group_by : str or list of str intervals are grouped by this/these ID column(s): these are exons belonging to same transcript path : st...
get_transcript_sequence
python
pyranges/pyranges
pyranges/get_fasta.py
https://github.com/pyranges/pyranges/blob/master/pyranges/get_fasta.py
MIT
def count_overlaps(grs, features=None, strandedness=None, how=None, nb_cpu=1): """Count overlaps in multiple pyranges. Parameters ---------- grs : dict of PyRanges The PyRanges to use as queries. features : PyRanges, default None The PyRanges to use as subject in the query. If No...
Count overlaps in multiple pyranges. Parameters ---------- grs : dict of PyRanges The PyRanges to use as queries. features : PyRanges, default None The PyRanges to use as subject in the query. If None, the PyRanges themselves are used as a query. strandedness : {None, "same", "o...
count_overlaps
python
pyranges/pyranges
pyranges/multioverlap.py
https://github.com/pyranges/pyranges/blob/master/pyranges/multioverlap.py
MIT
def fill_kwargs(kwargs): """Give the kwargs dict default options.""" defaults = { "strandedness": None, "overlap": True, "how": None, "invert": None, "new_pos": None, "suffixes": ["_a", "_b"], "suffix": "_b", "sparse": {"self": False, "other": Fal...
Give the kwargs dict default options.
fill_kwargs
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def __array_ufunc__(self, *args, **kwargs): """Apply unary numpy-function. Apply function to all columns which are not index, i.e. Chromosome, Start, End nor Strand. Notes ----- Function must produce a vector of equal length. Examples -------- ...
Apply unary numpy-function. Apply function to all columns which are not index, i.e. Chromosome, Start, End nor Strand. Notes ----- Function must produce a vector of equal length. Examples -------- >>> gr = pr.from_dict({"Chromosome": [1, 2, 3], "Star...
__array_ufunc__
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def __getattr__(self, name): """Return column. Parameters ---------- name : str Column to return Returns ------- pandas.Series Example ------- >>> gr = pr.from_dict({"Chromosome": [1, 1, 1], "Start": [0, 100, 250], "End": [...
Return column. Parameters ---------- name : str Column to return Returns ------- pandas.Series Example ------- >>> gr = pr.from_dict({"Chromosome": [1, 1, 1], "Start": [0, 100, 250], "End": [10, 125, 251]}) >>> gr.Start ...
__getattr__
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def __setattr__(self, column_name, column): """Insert or update column. Parameters ---------- column_name : str Name of column to update or insert. column : list, np.array or pd.Series Data to insert. Example ------- >>> gr = ...
Insert or update column. Parameters ---------- column_name : str Name of column to update or insert. column : list, np.array or pd.Series Data to insert. Example ------- >>> gr = pr.from_dict({"Chromosome": [1, 1, 1], "Start": [0, 100...
__setattr__
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def __getitem__(self, val): """Fetch columns or subset on position. If a list is provided, the column(s) in the list is returned. This subsets on columns. If a numpy array is provided, it must be of type bool and the same length as the PyRanges. Otherwise, a subset of the rows is retu...
Fetch columns or subset on position. If a list is provided, the column(s) in the list is returned. This subsets on columns. If a numpy array is provided, it must be of type bool and the same length as the PyRanges. Otherwise, a subset of the rows is returned with the location info provided. ...
__getitem__
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def apply(self, f, strand=None, as_pyranges=True, nb_cpu=1, **kwargs): """Apply a function to the PyRanges. Parameters ---------- f : function Function to apply on each DataFrame in a PyRanges strand : bool, default None, i.e. auto Whether to do operati...
Apply a function to the PyRanges. Parameters ---------- f : function Function to apply on each DataFrame in a PyRanges strand : bool, default None, i.e. auto Whether to do operations on chromosome/strand pairs or chromosomes. If None, will use chrom...
apply
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def apply_chunks(self, f, as_pyranges=False, nb_cpu=1, **kwargs): """Apply a row-based function to arbitrary partitions of the PyRanges. apply_chunks speeds up the application of functions where the result is not affected by applying the function to ordered, non-overlapping splits of the data. ...
Apply a row-based function to arbitrary partitions of the PyRanges. apply_chunks speeds up the application of functions where the result is not affected by applying the function to ordered, non-overlapping splits of the data. Parameters ---------- f : function Row-b...
apply_chunks
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def apply_pair(self, other, f, strandedness=None, as_pyranges=True, **kwargs): """Apply a function to a pair of PyRanges. The function is applied to each chromosome or chromosome/strand pair found in at least one of the PyRanges. Parameters ---------- f : function ...
Apply a function to a pair of PyRanges. The function is applied to each chromosome or chromosome/strand pair found in at least one of the PyRanges. Parameters ---------- f : function Row-based or associative function to apply on the DataFrames. strandedness...
apply_pair
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def as_df(self): """Return PyRanges as DataFrame. Returns ------- DataFrame A DataFrame natural sorted on Chromosome and Strand. The ordering of rows within chromosomes and strands is preserved. See also -------- PyRanges.df : Return Py...
Return PyRanges as DataFrame. Returns ------- DataFrame A DataFrame natural sorted on Chromosome and Strand. The ordering of rows within chromosomes and strands is preserved. See also -------- PyRanges.df : Return PyRanges as DataFrame. ...
as_df
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def assign(self, col, f, strand=None, nb_cpu=1, **kwargs): """Add or replace a column. Does not change the original PyRanges. Parameters ---------- col : str Name of column. f : function Function to create new column. strand : bool, d...
Add or replace a column. Does not change the original PyRanges. Parameters ---------- col : str Name of column. f : function Function to create new column. strand : bool, default None, i.e. auto Whether to do operations on chromo...
assign
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def boundaries(self, group_by, agg=None): """Return the boundaries of groups of intervals (e.g. transcripts) Parameters ---------- group_by : str or list of str Name(s) of column(s) to group intervals agg : dict or None Defines how to aggregate metada...
Return the boundaries of groups of intervals (e.g. transcripts) Parameters ---------- group_by : str or list of str Name(s) of column(s) to group intervals agg : dict or None Defines how to aggregate metadata columns. Provided as dictionary of col...
boundaries
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def calculate_frame(self, by): """Calculate the frame of each genomic interval, assuming all are coding sequences (CDS), and add it as column inplace. After this, the input Pyranges will contain an added "Frame" column, which determines the base of the CDS that is the first base of a codon. Res...
Calculate the frame of each genomic interval, assuming all are coding sequences (CDS), and add it as column inplace. After this, the input Pyranges will contain an added "Frame" column, which determines the base of the CDS that is the first base of a codon. Resulting values are in range between 0 and 2...
calculate_frame
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def cluster(self, strand=None, by=None, slack=0, count=False, nb_cpu=1): """Give overlapping intervals a common id. Parameters ---------- strand : bool, default None, i.e. auto Whether to ignore strand information if PyRanges is stranded. by : str or list, default ...
Give overlapping intervals a common id. Parameters ---------- strand : bool, default None, i.e. auto Whether to ignore strand information if PyRanges is stranded. by : str or list, default None Only intervals with an equal value in column(s) `by` are clustered...
cluster
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def columns(self): """Return the column labels of the PyRanges. Returns ------- pandas.Index See also -------- PyRanges.chromosomes : return the chromosomes in the PyRanges Examples -------- >>> f2 = pr.data.f2() >>> f2 ...
Return the column labels of the PyRanges. Returns ------- pandas.Index See also -------- PyRanges.chromosomes : return the chromosomes in the PyRanges Examples -------- >>> f2 = pr.data.f2() >>> f2 +--------------+-----------+--...
columns
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def count_overlaps( self, other, strandedness=None, keep_nonoverlapping=True, overlap_col="NumberOverlaps", ): """Count number of overlaps per interval. Count how many intervals in self overlap with those in other. Parameters ---------- ...
Count number of overlaps per interval. Count how many intervals in self overlap with those in other. Parameters ---------- strandedness : {"same", "opposite", None, False}, default None, i.e. auto Whether to perform the operation on the same, opposite or no strand. Use Fal...
count_overlaps
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def coverage( self, other, strandedness=None, keep_nonoverlapping=True, overlap_col="NumberOverlaps", fraction_col="FractionOverlaps", nb_cpu=1, ): """Count number of overlaps and their fraction per interval. Count how many intervals in self o...
Count number of overlaps and their fraction per interval. Count how many intervals in self overlap with those in other. Parameters ---------- strandedness : {"same", "opposite", None, False}, default None, i.e. auto Whether to perform the operation on the same, opposite or...
coverage
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def drop(self, drop=None, like=None): """Drop column(s). If no arguments are given, all the columns except Chromosome, Start, End and Strand are dropped. Parameters ---------- drop : str or list, default None Columns to drop. like : str, default N...
Drop column(s). If no arguments are given, all the columns except Chromosome, Start, End and Strand are dropped. Parameters ---------- drop : str or list, default None Columns to drop. like : str, default None Regex-string matching columns to...
drop
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def drop_duplicate_positions(self, strand=None, keep="first"): """Return PyRanges with duplicate postion rows removed. Parameters ---------- strand : bool, default None, i.e. auto Whether to take strand-information into account when considering duplicates. keep : ...
Return PyRanges with duplicate postion rows removed. Parameters ---------- strand : bool, default None, i.e. auto Whether to take strand-information into account when considering duplicates. keep : {"first", "last", False} Whether to keep first, last or drop ...
drop_duplicate_positions
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def extend(self, ext, group_by=None): """Extend the intervals from the ends. Parameters ---------- ext : int or dict of ints with "3" and/or "5" as keys. The number of nucleotides to extend the ends with. If an int is provided, the same extension is applied to ...
Extend the intervals from the ends. Parameters ---------- ext : int or dict of ints with "3" and/or "5" as keys. The number of nucleotides to extend the ends with. If an int is provided, the same extension is applied to both the start and end of intervals, ...
extend
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def five_end(self): """Return the five prime end of intervals. The five prime end is the start of a forward strand or the end of a reverse strand. Returns ------- PyRanges PyRanges with the five prime ends Notes ----- Requires the PyRanges...
Return the five prime end of intervals. The five prime end is the start of a forward strand or the end of a reverse strand. Returns ------- PyRanges PyRanges with the five prime ends Notes ----- Requires the PyRanges to be stranded. See A...
five_end
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def head(self, n=8): """Return the n first rows. Parameters ---------- n : int, default 8 Return n rows. Returns ------- PyRanges PyRanges with the n first rows. See Also -------- PyRanges.tail : return the la...
Return the n first rows. Parameters ---------- n : int, default 8 Return n rows. Returns ------- PyRanges PyRanges with the n first rows. See Also -------- PyRanges.tail : return the last rows PyRanges.sample ...
head
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def insert(self, other, loc=None): """Add one or more columns to the PyRanges. Parameters ---------- other : Series, DataFrame or dict Data to insert into the PyRanges. `other` must have the same number of rows as the PyRanges. loc : int, default None, i.e. after la...
Add one or more columns to the PyRanges. Parameters ---------- other : Series, DataFrame or dict Data to insert into the PyRanges. `other` must have the same number of rows as the PyRanges. loc : int, default None, i.e. after last column of PyRanges. Insertion i...
insert
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def intersect(self, other, strandedness=None, how=None, invert=False, nb_cpu=1): """Return overlapping subintervals. Returns the segments of the intervals in self which overlap with those in other. Parameters ---------- other : PyRanges PyRanges to intersect. ...
Return overlapping subintervals. Returns the segments of the intervals in self which overlap with those in other. Parameters ---------- other : PyRanges PyRanges to intersect. strandedness : {None, "same", "opposite", False}, default None, i.e. auto W...
intersect
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def join( self, other, strandedness=None, how=None, report_overlap=False, slack=0, suffix="_b", nb_cpu=1, apply_strand_suffix=None, preserve_order=False, ): """Join PyRanges on genomic location. Parameters -----...
Join PyRanges on genomic location. Parameters ---------- other : PyRanges PyRanges to join. strandedness : {None, "same", "opposite", False}, default None, i.e. auto Whether to compare PyRanges on the same strand, the opposite or ignore strand info...
join
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def k_nearest( self, other, k=1, ties=None, strandedness=None, overlap=True, how=None, suffix="_b", nb_cpu=1, apply_strand_suffix=None, ): """Find k nearest intervals. Parameters ---------- other : PyRan...
Find k nearest intervals. Parameters ---------- other : PyRanges PyRanges to find nearest interval in. k : int or list/array/Series of int Number of closest to return. If iterable, must be same length as PyRanges. ties : {None, "first", "last", "diffe...
k_nearest
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def lengths(self, as_dict=False): """Return the length of each interval. Parameters ---------- as_dict : bool, default False Whether to return lengths as Series or dict of Series per key. Returns ------- Series or dict of Series with the lengths of...
Return the length of each interval. Parameters ---------- as_dict : bool, default False Whether to return lengths as Series or dict of Series per key. Returns ------- Series or dict of Series with the lengths of each interval. See Also ---...
lengths
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def max_disjoint(self, strand=None, slack=0, **kwargs): """Find the maximal disjoint set of intervals. Parameters ---------- strand : bool, default None, i.e. auto Find the max disjoint set separately for each strand. slack : int, default 0 Consider in...
Find the maximal disjoint set of intervals. Parameters ---------- strand : bool, default None, i.e. auto Find the max disjoint set separately for each strand. slack : int, default 0 Consider intervals within a distance of slack to be overlapping. Retu...
max_disjoint
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def merge(self, strand=None, count=False, count_col="Count", by=None, slack=0): """Merge overlapping intervals into one. Parameters ---------- strand : bool, default None, i.e. auto Only merge intervals on same strand. count : bool, default False Count...
Merge overlapping intervals into one. Parameters ---------- strand : bool, default None, i.e. auto Only merge intervals on same strand. count : bool, default False Count intervals in each superinterval. count_col : str, default "Count" Na...
merge
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def nearest( self, other, strandedness=None, overlap=True, how=None, suffix="_b", nb_cpu=1, apply_strand_suffix=None, ): """Find closest interval. Parameters ---------- other : PyRanges PyRanges to find nea...
Find closest interval. Parameters ---------- other : PyRanges PyRanges to find nearest interval in. strandedness : {None, "same", "opposite", False}, default None, i.e. auto Whether to compare PyRanges on the same strand, the opposite or ignore strand ...
nearest
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def new_position(self, new_pos, columns=None): """Give new position. The operation join produces a PyRanges with two pairs of start coordinates and two pairs of end coordinates. This operation uses these to give the PyRanges a new position. Parameters ---------- new_pos...
Give new position. The operation join produces a PyRanges with two pairs of start coordinates and two pairs of end coordinates. This operation uses these to give the PyRanges a new position. Parameters ---------- new_pos : {"union", "intersection", "swap"} Change of...
new_position
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def overlap(self, other, strandedness=None, how="first", invert=False, nb_cpu=1): """Return overlapping intervals. Returns the intervals in self which overlap with those in other. Parameters ---------- other : PyRanges PyRanges to find overlaps with. stran...
Return overlapping intervals. Returns the intervals in self which overlap with those in other. Parameters ---------- other : PyRanges PyRanges to find overlaps with. strandedness : {None, "same", "opposite", False}, default None, i.e. auto Whether to ...
overlap
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def print(self, n=8, merge_position=False, sort=False, formatting=None, chain=False): """Print the PyRanges. Parameters ---------- n : int, default 8 The number of rows to print. merge_postion : bool, default False Print location in same column to sav...
Print the PyRanges. Parameters ---------- n : int, default 8 The number of rows to print. merge_postion : bool, default False Print location in same column to save screen space. sort : bool or str, default False Sort the PyRanges before ...
print
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def sample(self, n=8, replace=False): """Subsample arbitrary rows of PyRanges. If n is larger than length of PyRanges, replace must be True. Parameters ---------- n : int, default 8 Number of rows to return replace : bool, False Reuse rows. ...
Subsample arbitrary rows of PyRanges. If n is larger than length of PyRanges, replace must be True. Parameters ---------- n : int, default 8 Number of rows to return replace : bool, False Reuse rows. Examples -------- >>> gr ...
sample
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def set_intersect(self, other, strandedness=None, how=None, new_pos=False, nb_cpu=1): """Return set-theoretical intersection. Like intersect, but both PyRanges are merged first. Parameters ---------- other : PyRanges PyRanges to set-intersect. strandedness...
Return set-theoretical intersection. Like intersect, but both PyRanges are merged first. Parameters ---------- other : PyRanges PyRanges to set-intersect. strandedness : {None, "same", "opposite", False}, default None, i.e. auto Whether to compare PyR...
set_intersect
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def set_union(self, other, strandedness=None, nb_cpu=1): """Return set-theoretical union. Parameters ---------- other : PyRanges PyRanges to do union with. strandedness : {None, "same", "opposite", False}, default None, i.e. auto Whether to compare PyR...
Return set-theoretical union. Parameters ---------- other : PyRanges PyRanges to do union with. strandedness : {None, "same", "opposite", False}, default None, i.e. auto Whether to compare PyRanges on the same strand, the opposite or ignore strand ...
set_union
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def sort(self, by=None, nb_cpu=1): """Sort by position or columns. Parameters ---------- by : str or list of str, default None Column(s) to sort by. Default is Start and End. Special value "5" can be provided to sort by 5': intervals on + strand are sorted in as...
Sort by position or columns. Parameters ---------- by : str or list of str, default None Column(s) to sort by. Default is Start and End. Special value "5" can be provided to sort by 5': intervals on + strand are sorted in ascending order, while those on - st...
sort
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def spliced_subsequence(self, start=0, end=None, by=None, strand=None, **kwargs): """Get subsequences of the intervals, using coordinates mapping to spliced transcripts (without introns) The returned intervals are subregions of self, cut according to specifications. Start and end are relative t...
Get subsequences of the intervals, using coordinates mapping to spliced transcripts (without introns) The returned intervals are subregions of self, cut according to specifications. Start and end are relative to the 5' end: 0 means the leftmost nucleotide for + strand intervals, while it means ...
spliced_subsequence
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def split(self, strand=None, between=False, nb_cpu=1): """Split into non-overlapping intervals. Parameters ---------- strand : bool, default None, i.e. auto Whether to ignore strand information if PyRanges is stranded. between : bool, default False Inc...
Split into non-overlapping intervals. Parameters ---------- strand : bool, default None, i.e. auto Whether to ignore strand information if PyRanges is stranded. between : bool, default False Include lengths between intervals. nb_cpu: int, default 1 ...
split
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def stranded(self): """Whether PyRanges has (valid) strand info. Note ---- A PyRanges can have invalid values in the Strand-column. It is not considered stranded. See Also -------- PyRanges.strands : return the strands Examples -------- ...
Whether PyRanges has (valid) strand info. Note ---- A PyRanges can have invalid values in the Strand-column. It is not considered stranded. See Also -------- PyRanges.strands : return the strands Examples -------- >>> d = {'Chromosome': ['ch...
stranded
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def strands(self): """Return strands. Notes ----- If the strand-column contains an invalid value, [] is returned. See Also -------- PyRanges.stranded : whether has valid strand info Examples -------- >>> d = {'Chromosome': ['chr1', 'c...
Return strands. Notes ----- If the strand-column contains an invalid value, [] is returned. See Also -------- PyRanges.stranded : whether has valid strand info Examples -------- >>> d = {'Chromosome': ['chr1', 'chr1'], 'Start': [1, 6], ...
strands
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def subset(self, f, strand=None, **kwargs): """Return a subset of the rows. Parameters ---------- f : function Function which returns boolean Series equal to length of df. strand : bool, default None, i.e. auto Whether to do operations on chromosome/str...
Return a subset of the rows. Parameters ---------- f : function Function which returns boolean Series equal to length of df. strand : bool, default None, i.e. auto Whether to do operations on chromosome/strand pairs or chromosomes. If None, will use ...
subset
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def subsequence(self, start=0, end=None, by=None, strand=None, **kwargs): """Get subsequences of the intervals. The returned intervals are subregions of self, cut according to specifications. Start and end are relative to the 5' end: 0 means the leftmost nucleotide for + strand interval...
Get subsequences of the intervals. The returned intervals are subregions of self, cut according to specifications. Start and end are relative to the 5' end: 0 means the leftmost nucleotide for + strand intervals, while it means the rightmost one for - strand. This method also allows to ...
subsequence
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def subtract(self, other, strandedness=None, nb_cpu=1): """Subtract intervals. Parameters ---------- strandedness : {None, "same", "opposite", False}, default None, i.e. auto Whether to compare PyRanges on the same strand, the opposite or ignore strand informati...
Subtract intervals. Parameters ---------- strandedness : {None, "same", "opposite", False}, default None, i.e. auto Whether to compare PyRanges on the same strand, the opposite or ignore strand information. The default, None, means use "same" if both PyRanges are strand...
subtract
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def summary(self, to_stdout=True, return_df=False): """Return info. Count refers to the number of intervals, the rest to the lengths. The column "pyrange" describes the data as is. "coverage_forward" and "coverage_reverse" describe the data after strand-specific merging of overlapping ...
Return info. Count refers to the number of intervals, the rest to the lengths. The column "pyrange" describes the data as is. "coverage_forward" and "coverage_reverse" describe the data after strand-specific merging of overlapping intervals. "coverage_unstranded" describes the data aft...
summary
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def tail(self, n=8): """Return the n last rows. Parameters ---------- n : int, default 8 Return n rows. Returns ------- PyRanges PyRanges with the n last rows. See Also -------- PyRanges.head : return the firs...
Return the n last rows. Parameters ---------- n : int, default 8 Return n rows. Returns ------- PyRanges PyRanges with the n last rows. See Also -------- PyRanges.head : return the first rows PyRanges.sample :...
tail
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def tile(self, tile_size, overlap=False, strand=None, nb_cpu=1): """Return overlapping genomic tiles. The genome is divided into bookended tiles of length `tile_size` and one is returned per overlapping interval. Parameters ---------- tile_size : int Length ...
Return overlapping genomic tiles. The genome is divided into bookended tiles of length `tile_size` and one is returned per overlapping interval. Parameters ---------- tile_size : int Length of the tiles. overlap : bool, default False Add column...
tile
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def to_example(self, n=10): """Return as dict. Used for easily creating examples for copy and pasting. Parameters ---------- n : int, default 10 Number of rows. Half is taken from the start, the other half from the end. See Also -------- Py...
Return as dict. Used for easily creating examples for copy and pasting. Parameters ---------- n : int, default 10 Number of rows. Half is taken from the start, the other half from the end. See Also -------- PyRanges.from_dict : create PyRanges from...
to_example
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def three_end(self): """Return the 3'-end. The 3'-end is the start of intervals on the reverse strand and the end of intervals on the forward strand. Returns ------- PyRanges PyRanges with the 3'. See Also -------- PyRanges.five_end ...
Return the 3'-end. The 3'-end is the start of intervals on the reverse strand and the end of intervals on the forward strand. Returns ------- PyRanges PyRanges with the 3'. See Also -------- PyRanges.five_end : return the five prime end ...
three_end
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def to_bed(self, path=None, keep=True, compression="infer", chain=False): r"""Write to bed. Parameters ---------- path : str, default None Where to write. If None, returns string representation. keep : bool, default True Whether to keep all columns, not...
Write to bed. Parameters ---------- path : str, default None Where to write. If None, returns string representation. keep : bool, default True Whether to keep all columns, not just Chromosome, Start, End, Name, Score, Strand when writing. c...
to_bed
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def to_bigwig( self, path=None, chromosome_sizes=None, rpm=True, divide=None, value_col=None, dryrun=False, chain=False, ): """Write regular or value coverage to bigwig. Note ---- To create one bigwig per strand, subse...
Write regular or value coverage to bigwig. Note ---- To create one bigwig per strand, subset the PyRanges first. Parameters ---------- path : str Where to write bigwig. chromosome_sizes : PyRanges or dict If dict: map of chromosome na...
to_bigwig
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def to_rle(self, value_col=None, strand=None, rpm=False, nb_cpu=1): """Return as RleDict. Create collection of Rles representing the coverage or other numerical value. Parameters ---------- value_col : str, default None Numerical column to create RleDict from. ...
Return as RleDict. Create collection of Rles representing the coverage or other numerical value. Parameters ---------- value_col : str, default None Numerical column to create RleDict from. strand : bool, default None, i.e. auto Whether to treat strands...
to_rle
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def unstrand(self): """Remove strand. Note ---- Removes Strand column even if PyRanges is not stranded. See Also -------- PyRanges.stranded : whether PyRanges contains valid strand info. Examples -------- >>> d = {'Chromosome': ['chr...
Remove strand. Note ---- Removes Strand column even if PyRanges is not stranded. See Also -------- PyRanges.stranded : whether PyRanges contains valid strand info. Examples -------- >>> d = {'Chromosome': ['chr1', 'chr1'], 'Start': [1, 6], ...
unstrand
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def window(self, window_size, strand=None): """Return overlapping genomic windows. Windows of length `window_size` are returned. Parameters ---------- window_size : int Length of the windows. strand : bool, default None, i.e. auto Whether to do...
Return overlapping genomic windows. Windows of length `window_size` are returned. Parameters ---------- window_size : int Length of the windows. strand : bool, default None, i.e. auto Whether to do operations on chromosome/strand pairs or chromosomes. ...
window
python
pyranges/pyranges
pyranges/pyranges_main.py
https://github.com/pyranges/pyranges/blob/master/pyranges/pyranges_main.py
MIT
def rename_core_attrs(df, ftype, rename_attr=False): """Deduplicate columns from GTF attributes that share names with the default 8 columns by appending "_attr" to each name if rename_attr==True. Otherwise throw an error informing user of formatting issues. Parameters ---------- df : pandas...
Deduplicate columns from GTF attributes that share names with the default 8 columns by appending "_attr" to each name if rename_attr==True. Otherwise throw an error informing user of formatting issues. Parameters ---------- df : pandas DataFrame DataFrame from read_gtf ftype : str...
rename_core_attrs
python
pyranges/pyranges
pyranges/readers.py
https://github.com/pyranges/pyranges/blob/master/pyranges/readers.py
MIT
def read_bam(f, sparse=True, as_df=False, mapq=0, required_flag=0, filter_flag=1540): """Return bam file as PyRanges. Parameters ---------- f : str Path to bam file sparse : bool, default True Whether to return only. as_df : bool, default False Whether to return as ...
Return bam file as PyRanges. Parameters ---------- f : str Path to bam file sparse : bool, default True Whether to return only. as_df : bool, default False Whether to return as pandas DataFrame instead of PyRanges. mapq : int, default 0 Minimum mapping qua...
read_bam
python
pyranges/pyranges
pyranges/readers.py
https://github.com/pyranges/pyranges/blob/master/pyranges/readers.py
MIT
def read_gtf( f, full=True, as_df=False, nrows=None, duplicate_attr=False, rename_attr=False, ignore_bad: bool = False, ): """Read files in the Gene Transfer Format. Parameters ---------- f : str Path to GTF file. full : bool, default True Whether to r...
Read files in the Gene Transfer Format. Parameters ---------- f : str Path to GTF file. full : bool, default True Whether to read and interpret the annotation column. as_df : bool, default False Whether to return as pandas DataFrame instead of PyRanges. nrows : int...
read_gtf
python
pyranges/pyranges
pyranges/readers.py
https://github.com/pyranges/pyranges/blob/master/pyranges/readers.py
MIT
def read_gtf_restricted(f, skiprows, as_df=False, nrows=None): """seqname - name of the chromosome or scaffold; chromosome names can be given with or without the 'chr' prefix. Important note: the seqname must be one used within Ensembl, i.e. a standard chromosome name or an Ensembl identifier such as a scaffold ID,...
seqname - name of the chromosome or scaffold; chromosome names can be given with or without the 'chr' prefix. Important note: the seqname must be one used within Ensembl, i.e. a standard chromosome name or an Ensembl identifier such as a scaffold ID, without any additional content such as species or assembly. See the e...
read_gtf_restricted
python
pyranges/pyranges
pyranges/readers.py
https://github.com/pyranges/pyranges/blob/master/pyranges/readers.py
MIT
def read_gff3(f, full=True, annotation=None, as_df=False, nrows=None): """Read files in the General Feature Format. Parameters ---------- f : str Path to GFF file. full : bool, default True Whether to read and interpret the annotation column. as_df : bool, default False ...
Read files in the General Feature Format. Parameters ---------- f : str Path to GFF file. full : bool, default True Whether to read and interpret the annotation column. as_df : bool, default False Whether to return as pandas DataFrame instead of PyRanges. nrows : i...
read_gff3
python
pyranges/pyranges
pyranges/readers.py
https://github.com/pyranges/pyranges/blob/master/pyranges/readers.py
MIT
def fdr(p_vals): """Adjust p-values with Benjamini-Hochberg. Parameters ---------- data : array-like Returns ------- Pandas.DataFrame DataFrame where values are order of data. Examples -------- >>> d = {'Chromosome': ['chr3', 'chr6', 'chr13'], 'Start': [146419383, 3...
Adjust p-values with Benjamini-Hochberg. Parameters ---------- data : array-like Returns ------- Pandas.DataFrame DataFrame where values are order of data. Examples -------- >>> d = {'Chromosome': ['chr3', 'chr6', 'chr13'], 'Start': [146419383, 39800100, 24537618], 'End...
fdr
python
pyranges/pyranges
pyranges/statistics.py
https://github.com/pyranges/pyranges/blob/master/pyranges/statistics.py
MIT
def fisher_exact(tp, fp, fn, tn, pseudocount=0): """Fisher's exact for contingency tables. Computes the hypotheses two-sided, less and greater at the same time. The odds-ratio is Parameters ---------- tp : array-like of int Top left square of contingency table (true positives). ...
Fisher's exact for contingency tables. Computes the hypotheses two-sided, less and greater at the same time. The odds-ratio is Parameters ---------- tp : array-like of int Top left square of contingency table (true positives). fp : array-like of int Top right square of cont...
fisher_exact
python
pyranges/pyranges
pyranges/statistics.py
https://github.com/pyranges/pyranges/blob/master/pyranges/statistics.py
MIT
def mcc(grs, genome=None, labels=None, strand=False, verbose=False): """Compute Matthew's correlation coefficient for PyRanges overlaps. Parameters ---------- grs : list of PyRanges PyRanges to compare. genome : DataFrame or dict, default None Should contain chromosome sizes. By ...
Compute Matthew's correlation coefficient for PyRanges overlaps. Parameters ---------- grs : list of PyRanges PyRanges to compare. genome : DataFrame or dict, default None Should contain chromosome sizes. By default, end position of the rightmost intervals are used as proxies...
mcc
python
pyranges/pyranges
pyranges/statistics.py
https://github.com/pyranges/pyranges/blob/master/pyranges/statistics.py
MIT
def rowbased_spearman(x, y): """Fast row-based Spearman's correlation. Parameters ---------- x : matrix-like 2D numerical matrix. Same size as y. y : matrix-like 2D numerical matrix. Same size as x. Returns ------- numpy.array Array with same length as input...
Fast row-based Spearman's correlation. Parameters ---------- x : matrix-like 2D numerical matrix. Same size as y. y : matrix-like 2D numerical matrix. Same size as x. Returns ------- numpy.array Array with same length as input, where values are P-values. Se...
rowbased_spearman
python
pyranges/pyranges
pyranges/statistics.py
https://github.com/pyranges/pyranges/blob/master/pyranges/statistics.py
MIT
def rowbased_pearson(x, y): """Fast row-based Pearson's correlation. Parameters ---------- x : matrix-like 2D numerical matrix. Same size as y. y : matrix-like 2D numerical matrix. Same size as x. Returns ------- numpy.array Array with same length as input, ...
Fast row-based Pearson's correlation. Parameters ---------- x : matrix-like 2D numerical matrix. Same size as y. y : matrix-like 2D numerical matrix. Same size as x. Returns ------- numpy.array Array with same length as input, where values are P-values. See...
rowbased_pearson
python
pyranges/pyranges
pyranges/statistics.py
https://github.com/pyranges/pyranges/blob/master/pyranges/statistics.py
MIT
def rowbased_rankdata(data): """Rank order of entries in each row. Same as SciPy rankdata with method=mean. Parameters ---------- data : matrix-like The data to find order of. Returns ------- Pandas.DataFrame DataFrame where values are order of data. Examples ...
Rank order of entries in each row. Same as SciPy rankdata with method=mean. Parameters ---------- data : matrix-like The data to find order of. Returns ------- Pandas.DataFrame DataFrame where values are order of data. Examples -------- >>> x = np.random.ra...
rowbased_rankdata
python
pyranges/pyranges
pyranges/statistics.py
https://github.com/pyranges/pyranges/blob/master/pyranges/statistics.py
MIT
def simes(df, groupby, pcol, keep_position=False): """Apply Simes method for giving dependent events a p-value. Parameters ---------- df : pandas.DataFrame Data to analyse with Simes. groupby : str or list of str Features equal in these columns will be merged with Simes. pco...
Apply Simes method for giving dependent events a p-value. Parameters ---------- df : pandas.DataFrame Data to analyse with Simes. groupby : str or list of str Features equal in these columns will be merged with Simes. pcol : str Name of column with p-values. keep_p...
simes
python
pyranges/pyranges
pyranges/statistics.py
https://github.com/pyranges/pyranges/blob/master/pyranges/statistics.py
MIT
def forbes(self, other, chromsizes, strandedness=None): """Compute Forbes coefficient. Ratio which represents observed versus expected co-occurence. Described in ``Forbes SA (1907): On the local distribution of certain Illinois fishes: an essay in statistical ecology.`` Parameters ...
Compute Forbes coefficient. Ratio which represents observed versus expected co-occurence. Described in ``Forbes SA (1907): On the local distribution of certain Illinois fishes: an essay in statistical ecology.`` Parameters ---------- other : PyRanges Intervals to ...
forbes
python
pyranges/pyranges
pyranges/statistics.py
https://github.com/pyranges/pyranges/blob/master/pyranges/statistics.py
MIT
def jaccard(self, other, **kwargs): """Compute Jaccards coefficient. Ratio of the intersection and union of two sets. Parameters ---------- other : PyRanges Intervals to compare with. chromsizes : int, dict, DataFrame or PyRanges Integer repre...
Compute Jaccards coefficient. Ratio of the intersection and union of two sets. Parameters ---------- other : PyRanges Intervals to compare with. chromsizes : int, dict, DataFrame or PyRanges Integer representing genome length or mapping from chromosom...
jaccard
python
pyranges/pyranges
pyranges/statistics.py
https://github.com/pyranges/pyranges/blob/master/pyranges/statistics.py
MIT
def relative_distance(self, other, **kwargs): """Compute spatial correllation between two sets. Metric which describes relative distance between each interval in one set and two closest intervals in another. Parameters ---------- other : PyRanges Intervals ...
Compute spatial correllation between two sets. Metric which describes relative distance between each interval in one set and two closest intervals in another. Parameters ---------- other : PyRanges Intervals to compare with. chromsizes : int, dict, DataFra...
relative_distance
python
pyranges/pyranges
pyranges/statistics.py
https://github.com/pyranges/pyranges/blob/master/pyranges/statistics.py
MIT
def from_string(s, int64=False): """Create a PyRanges from multiline string. Parameters ---------- s : str String with data. int64 : bool, default False. Whether to use 64-bit integers for starts and ends. See Also -------- pyranges.from_dict : create a PyRanges fro...
Create a PyRanges from multiline string. Parameters ---------- s : str String with data. int64 : bool, default False. Whether to use 64-bit integers for starts and ends. See Also -------- pyranges.from_dict : create a PyRanges from a dictionary. Examples ------...
from_string
python
pyranges/pyranges
pyranges/__init__.py
https://github.com/pyranges/pyranges/blob/master/pyranges/__init__.py
MIT
def itergrs(prs, strand=None, keys=False): r"""Iterate over multiple PyRanges at once. Parameters ---------- prs : list of PyRanges PyRanges to iterate over. strand : bool, default None, i.e. auto Whether to iterate over strands. If True, all PyRanges must be stranded. keys ...
Iterate over multiple PyRanges at once. Parameters ---------- prs : list of PyRanges PyRanges to iterate over. strand : bool, default None, i.e. auto Whether to iterate over strands. If True, all PyRanges must be stranded. keys : bool, default False Return tuple with ke...
itergrs
python
pyranges/pyranges
pyranges/__init__.py
https://github.com/pyranges/pyranges/blob/master/pyranges/__init__.py
MIT
def random(n=1000, length=100, chromsizes=None, strand=True, int64=False, seed=None): """Return PyRanges with random intervals. Parameters ---------- n : int, default 1000 Number of intervals. length : int, default 100 Length of intervals. chromsizes : dict or DataFrame, def...
Return PyRanges with random intervals. Parameters ---------- n : int, default 1000 Number of intervals. length : int, default 100 Length of intervals. chromsizes : dict or DataFrame, default None, i.e. use "hg19" Draw intervals from within these bounds. strand : bo...
random
python
pyranges/pyranges
pyranges/__init__.py
https://github.com/pyranges/pyranges/blob/master/pyranges/__init__.py
MIT
def to_bigwig(gr, path, chromosome_sizes): """Write df to bigwig. Must contain the columns Chromosome, Start, End and Score. All others are ignored. Parameters ---------- path : str Where to write bigwig. chromosome_sizes : PyRanges or dict If dict: map of chromosome names t...
Write df to bigwig. Must contain the columns Chromosome, Start, End and Score. All others are ignored. Parameters ---------- path : str Where to write bigwig. chromosome_sizes : PyRanges or dict If dict: map of chromosome names to chromosome length. Examples -------- ...
to_bigwig
python
pyranges/pyranges
pyranges/__init__.py
https://github.com/pyranges/pyranges/blob/master/pyranges/__init__.py
MIT
def _handle_eval_return(self, result, col, as_pyranges, subset): """Handle return from eval. If col is set, add/update cols. If subset is True, use return series to subset PyRanges. Otherwise return PyRanges or dict of data.""" if as_pyranges: if not result: return pr.PyRanges() ...
Handle return from eval. If col is set, add/update cols. If subset is True, use return series to subset PyRanges. Otherwise return PyRanges or dict of data.
_handle_eval_return
python
pyranges/pyranges
pyranges/methods/call.py
https://github.com/pyranges/pyranges/blob/master/pyranges/methods/call.py
MIT
def sort_one_by_one(d, col1, col2): """ Equivalent to pd.sort_values(by=[col1, col2]), but faster. """ d = d.sort_values(by=[col2]) return d.sort_values(by=[col1], kind="mergesort")
Equivalent to pd.sort_values(by=[col1, col2]), but faster.
sort_one_by_one
python
pyranges/pyranges
pyranges/methods/sort.py
https://github.com/pyranges/pyranges/blob/master/pyranges/methods/sort.py
MIT
def _introns_correct(full, genes, exons, introns, by): """Testing that introns: 1: ends larger than starts 2: the intersection of the computed introns and exons per gene are 0 3: that the number of introns overlapping each gene is the same as number of introns per gene 4 & 5: that the intron positi...
Testing that introns: 1: ends larger than starts 2: the intersection of the computed introns and exons per gene are 0 3: that the number of introns overlapping each gene is the same as number of introns per gene 4 & 5: that the intron positions are the same as the ones computed with the slow, but corre...
_introns_correct
python
pyranges/pyranges
tests/unit/test_genomicfeatures.py
https://github.com/pyranges/pyranges/blob/master/tests/unit/test_genomicfeatures.py
MIT
def test_introns_single(): "Assert that our fast method of computing introns is the same as the slow, correct one in compute_introns_single" gr = pr.data.gencode_gtf()[["gene_id", "Feature"]] exons = gr[gr.Feature == "exon"].merge(by="gene_id") exons.Feature = "exon" exons = exons.df df = pd.co...
Assert that our fast method of computing introns is the same as the slow, correct one in compute_introns_single
test_introns_single
python
pyranges/pyranges
tests/unit/test_genomicfeatures.py
https://github.com/pyranges/pyranges/blob/master/tests/unit/test_genomicfeatures.py
MIT
def makecube(): """ Generate vertices & indices for a filled cube """ vtype = [('a_position', np.float32, 3), ('a_texcoord', np.float32, 2)] itype = np.uint32 # Vertices positions p = np.array([[1, 1, 1], [-1, 1, 1], [-1, -1, 1], [1, -1, 1], [1, -1, -1], [1, 1, -1], ...
Generate vertices & indices for a filled cube
makecube
python
timctho/VNect-tensorflow
vispy_test.py
https://github.com/timctho/VNect-tensorflow/blob/master/vispy_test.py
Apache-2.0
def _create_base_cipher(dict_parameters): """This method instantiates and returns a handle to a low-level base cipher. It will absorb named parameters in the process.""" use_aesni = dict_parameters.pop("use_aesni", True) try: key = dict_parameters.pop("key") except KeyError: raise ...
This method instantiates and returns a handle to a low-level base cipher. It will absorb named parameters in the process.
_create_base_cipher
python
mchristopher/PokemonGo-DesktopMap
app/pylibs/osx64/Cryptodome/Cipher/AES.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Cipher/AES.py
MIT
def new(key, mode, *args, **kwargs): """Create a new AES cipher :Parameters: key : byte string The secret key to use in the symmetric cipher. It must be 16 (*AES-128*), 24 (*AES-192*), or 32 (*AES-256*) bytes long. Only in `MODE_SIV`, it needs to be 32, 48, or 64 bytes lo...
Create a new AES cipher :Parameters: key : byte string The secret key to use in the symmetric cipher. It must be 16 (*AES-128*), 24 (*AES-192*), or 32 (*AES-256*) bytes long. Only in `MODE_SIV`, it needs to be 32, 48, or 64 bytes long. mode : a *MODE_** constant ...
new
python
mchristopher/PokemonGo-DesktopMap
app/pylibs/osx64/Cryptodome/Cipher/AES.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Cipher/AES.py
MIT
def _create_base_cipher(dict_parameters): """This method instantiates and returns a handle to a low-level base cipher. It will absorb named parameters in the process.""" try: key = dict_parameters.pop("key") except KeyError: raise TypeError("Missing 'key' parameter") effective_keyl...
This method instantiates and returns a handle to a low-level base cipher. It will absorb named parameters in the process.
_create_base_cipher
python
mchristopher/PokemonGo-DesktopMap
app/pylibs/osx64/Cryptodome/Cipher/ARC2.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Cipher/ARC2.py
MIT
def __init__(self, key, *args, **kwargs): """Initialize an ARC4 cipher object See also `new()` at the module level.""" if len(args) > 0: ndrop = args[0] args = args[1:] else: ndrop = kwargs.pop('drop', 0) if len(key) not in key_size: ...
Initialize an ARC4 cipher object See also `new()` at the module level.
__init__
python
mchristopher/PokemonGo-DesktopMap
app/pylibs/osx64/Cryptodome/Cipher/ARC4.py
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/master/app/pylibs/osx64/Cryptodome/Cipher/ARC4.py
MIT