def encode(self, dataset, params: EncoderParams):
        EncoderHelper.check_positive_class_label(
            CompAIRRSequenceAbundanceEncoder.__name__,
            params.label_config.get_label_objects())
        self._prepare_sequence_presence_data(dataset, params)
        encoded_dataset = self._encode_data(dataset, params)

        return encoded_dataset
    def encode(self, dataset, params: EncoderParams):

        EncoderHelper.check_positive_class_label(
            SequenceAbundanceEncoder.__name__,
            params.label_config.get_label_objects())

        self.comparison_data = SequenceFilterHelper.build_comparison_data(
            dataset, self.context, self.comparison_attributes, params,
            self.sequence_batch_size)
        return self._encode_data(dataset, params)
Beispiel #3
0
    def encode(self, dataset, params: EncoderParams):
        cache_params = self._prepare_caching_params(dataset, params)
        encoded_dataset = CacheHandler.memo_by_params(
            cache_params, lambda: self._encode_new_dataset(dataset, params))

        EncoderHelper.sync_encoder_with_cache(
            cache_params, lambda: {
                'model_path': self.model_path,
                'scaler': self.scaler
            }, self, ['model_path', 'scaler'])

        return encoded_dataset
Beispiel #4
0
    def build_comparison_data(dataset: RepertoireDataset, context: dict,
                              comparison_attributes: list,
                              params: EncoderParams, sequence_batch_size: int):

        current_dataset = EncoderHelper.get_current_dataset(dataset, context)
        comparison_data = CacheHandler.memo_by_params(
            EncoderHelper.build_comparison_params(current_dataset,
                                                  comparison_attributes),
            lambda: EncoderHelper.build_comparison_data(
                current_dataset, params, comparison_attributes,
                sequence_batch_size))

        return comparison_data
    def _prepare_sequence_presence_data(self, dataset, params):
        full_dataset = EncoderHelper.get_current_dataset(dataset, self.context)

        full_sequence_set = self._get_full_sequence_set(full_dataset)
        sequence_presence_matrix, matrix_repertoire_ids = self._get_sequence_presence(
            full_dataset, full_sequence_set, params)

        self.full_sequence_set = full_sequence_set
        self.sequence_presence_matrix = sequence_presence_matrix
        self.matrix_repertoire_ids = matrix_repertoire_ids
Beispiel #6
0
    def encode(self, dataset, params: EncoderParams) -> RepertoireDataset:

        train_repertoire_ids = EncoderHelper.prepare_training_ids(dataset, params)
        distance_matrix = self.build_distance_matrix(dataset, params, train_repertoire_ids)
        labels = self.build_labels(dataset, params) if params.encode_labels else None

        encoded_dataset = dataset.clone()
        encoded_dataset.encoded_data = EncodedData(examples=distance_matrix, labels=labels, example_ids=distance_matrix.index.values,
                                                   encoding=DistanceEncoder.__name__)

        return encoded_dataset
Beispiel #7
0
    def encode(self, dataset, params: EncoderParams):
        train_receptor_ids = EncoderHelper.prepare_training_ids(
            dataset, params)
        if params.learn_model:
            self._build_tcr_dist_matrix(
                dataset, params.label_config.get_labels_by_name())

        distance_matrix = self.distance_matrix.loc[dataset.get_example_ids(),
                                                   train_receptor_ids]
        labels = self._build_labels(dataset,
                                    params) if params.encode_labels else None

        encoded_dataset = dataset.clone()
        encoded_dataset.encoded_data = EncodedData(
            examples=distance_matrix,
            labels=labels,
            example_ids=distance_matrix.index.values,
            encoding=TCRdistEncoder.__name__)

        return encoded_dataset
Beispiel #8
0
 def store(self, encoded_dataset, params: EncoderParams):
     EncoderHelper.store(encoded_dataset, params)