immuneML.encodings.kmer_frequency package
Subpackages
- immuneML.encodings.kmer_frequency.sequence_encoding package
- Submodules
- immuneML.encodings.kmer_frequency.sequence_encoding.GappedKmerSequenceEncoder module
- immuneML.encodings.kmer_frequency.sequence_encoding.IMGTGappedKmerEncoder module
- immuneML.encodings.kmer_frequency.sequence_encoding.IMGTKmerSequenceEncoder module
- immuneML.encodings.kmer_frequency.sequence_encoding.IdentitySequenceEncoder module
- immuneML.encodings.kmer_frequency.sequence_encoding.KmerSequenceEncoder module
- immuneML.encodings.kmer_frequency.sequence_encoding.SequenceEncodingStrategy module
- immuneML.encodings.kmer_frequency.sequence_encoding.SequenceEncodingType module
- Module contents
Submodules
immuneML.encodings.kmer_frequency.KmerFreqReceptorEncoder module
- class immuneML.encodings.kmer_frequency.KmerFreqReceptorEncoder.KmerFreqReceptorEncoder(normalization_type: NormalizationType, reads: ReadsType, sequence_encoding: SequenceEncodingType, k: int = 0, k_left: int = 0, k_right: int = 0, min_gap: int = 0, max_gap: int = 0, metadata_fields_to_include: list = None, name: str = None, scale_to_unit_variance: bool = False, scale_to_zero_mean: bool = False, sequence_type: SequenceType = None)[source]
Bases:
KmerFrequencyEncoder
immuneML.encodings.kmer_frequency.KmerFreqRepertoireEncoder module
- class immuneML.encodings.kmer_frequency.KmerFreqRepertoireEncoder.KmerFreqRepertoireEncoder(normalization_type: NormalizationType, reads: ReadsType, sequence_encoding: SequenceEncodingType, k: int = 0, k_left: int = 0, k_right: int = 0, min_gap: int = 0, max_gap: int = 0, metadata_fields_to_include: list = None, name: str = None, scale_to_unit_variance: bool = False, scale_to_zero_mean: bool = False, sequence_type: SequenceType = None)[source]
Bases:
KmerFrequencyEncoder
- encode_repertoire(repertoire, params: EncoderParams)[source]
- get_encoded_repertoire(repertoire, params: EncoderParams)[source]
immuneML.encodings.kmer_frequency.KmerFreqSequenceEncoder module
- class immuneML.encodings.kmer_frequency.KmerFreqSequenceEncoder.KmerFreqSequenceEncoder(normalization_type: NormalizationType, reads: ReadsType, sequence_encoding: SequenceEncodingType, k: int = 0, k_left: int = 0, k_right: int = 0, min_gap: int = 0, max_gap: int = 0, metadata_fields_to_include: list = None, name: str = None, scale_to_unit_variance: bool = False, scale_to_zero_mean: bool = False, sequence_type: SequenceType = None)[source]
Bases:
KmerFrequencyEncoder
immuneML.encodings.kmer_frequency.KmerFrequencyEncoder module
- class immuneML.encodings.kmer_frequency.KmerFrequencyEncoder.KmerFrequencyEncoder(normalization_type: NormalizationType, reads: ReadsType, sequence_encoding: SequenceEncodingType, k: int = 0, k_left: int = 0, k_right: int = 0, min_gap: int = 0, max_gap: int = 0, metadata_fields_to_include: list = None, name: str = None, scale_to_unit_variance: bool = False, scale_to_zero_mean: bool = False, sequence_type: SequenceType = None)[source]
Bases:
DatasetEncoder
The KmerFrequencyEncoder class encodes a repertoire, sequence or receptor by frequencies of k-mers it contains. A k-mer is a sequence of letters of length k into which an immune receptor sequence can be decomposed. K-mers can be defined in different ways, as determined by the sequence_encoding.
- Parameters:
sequence_encoding (
SequenceEncodingType
) – The type of k-mers that are used. The simplest sequence_encoding isCONTINUOUS_KMER
, which uses contiguous subsequences of length k to represent the k-mers. When gapped k-mers are used (GAPPED_KMER
,GAPPED_KMER
), the k-mers may contain gaps with a size between min_gap and max_gap, and the k-mer length is defined as a combination of k_left and k_right. When IMGT k-mers are used (IMGT_CONTINUOUS_KMER
,IMGT_GAPPED_KMER
), IMGT positional information is taken into account (i.e. the same sequence in a different position is considered to be a different k-mer). When the identity representation is used (IDENTITY
), the k-mers just correspond to the original sequences.normalization_type (
NormalizationType
) – The way in which the k-mer frequencies should be normalized. The default value for normalization_type is l2.reads (
ReadsType
) – Reads type signify whether the counts of the sequences in the repertoire will be taken into account. IfUNIQUE
, only unique sequences (clonotypes) are encoded, and ifALL
, the sequence ‘count’ value is taken into account when determining the k-mer frequency. The default value for reads is unique.k (int) – Length of the k-mer (number of amino acids) when ungapped k-mers are used. The default value for k is 3.
k_left (int) – When gapped k-mers are used, k_left indicates the length of the k-mer left of the gap. The default value for k_left is 1.
k_right (int) – Same as k_left, but k_right determines the length of the k-mer right of the gap. The default value for k_right is 1.
min_gap (int) – Minimum gap size when gapped k-mers are used. The default value for min_gap is 0.
max_gap – (int): Maximum gap size when gapped k-mers are used. The default value for max_gap is 0.
sequence_type (
SequenceType
) – Whether to work with nucleotide or amino acid sequences. Amino acid sequences are the default. To work with either sequence type, the sequences of the desired type should be included in the datasets, e.g., listed under ‘columns_to_load’ parameter. By default, both types will be included if available. Valid values are: AMINO_ACID and NUCLEOTIDE.scale_to_unit_variance (bool) – whether to scale the design matrix after normalization to have unit variance per feature. Setting this argument to True might improve the subsequent classifier’s performance depending on the type of the classifier. The default value for scale_to_unit_variance is true.
scale_to_zero_mean (bool) – whether to scale the design matrix after normalization to have zero mean per feature. Setting this argument to True might improve the subsequent classifier’s performance depending on the type of the classifier. However, if the original design matrix was sparse, setting this argument to True will destroy the sparsity and will increase the memory consumption. The default value for scale_to_zero_mean is false.
YAML specification:
my_continuous_kmer: KmerFrequency: normalization_type: RELATIVE_FREQUENCY reads: UNIQUE sequence_encoding: CONTINUOUS_KMER sequence_type: NUCLEOTIDE k: 3 scale_to_unit_variance: True scale_to_zero_mean: True my_gapped_kmer: KmerFrequency: normalization_type: RELATIVE_FREQUENCY reads: UNIQUE sequence_encoding: GAPPED_KMER sequence_type: AMINO_ACID k_left: 2 k_right: 2 min_gap: 1 max_gap: 3 scale_to_unit_variance: True scale_to_zero_mean: False
- STEP_ENCODED = 'encoded'
- STEP_NORMALIZED = 'normalized'
- STEP_SCALED = 'scaled'
- STEP_VECTORIZED = 'vectorized'
- dataset_mapping = {'ReceptorDataset': 'KmerFreqReceptorEncoder', 'RepertoireDataset': 'KmerFreqRepertoireEncoder', 'SequenceDataset': 'KmerFreqSequenceEncoder'}
- encode(dataset, params: EncoderParams)[source]