From aa5a66710b2c164ea6520ecb598cb5b004d97782 Mon Sep 17 00:00:00 2001 From: KrystynaGrzesiak Date: Fri, 2 Aug 2024 14:15:03 +0200 Subject: [PATCH 1/2] changes a bit output of generate_sequences --- R/sequences.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/sequences.R b/R/sequences.R index c084f21..3fe3ace 100644 --- a/R/sequences.R +++ b/R/sequences.R @@ -76,6 +76,7 @@ generate_sequence_data <- function(n_seq, attr(sequences, "motifs_map") <- motifs_map attr(sequences, "masks") <- list_of_masks attr(sequences, "target") <- target + attr(sequences, "motifs_set") <- motifs sequences } @@ -182,7 +183,7 @@ generate_kmer_data <- function(n_seq, nrow = nrow(test_dat), ncol = ncol(test_dat)) attr(test_res, "max_injection") <- attr(test_dat, "max_injection") - attr(test_res, "motifs_set") <- motifs + attr(test_res, "motifs_set") <- attr(test_dat, "motifs_set") attr(test_res, "motifs_map") <- attr(test_dat, "motifs_map") attr(test_res, "masks") <- attr(test_dat, "masks") attr(test_res, "target") <- attr(test_dat, "target") From b9f78e00880f6787ca42d8827b6e8ed636be0c0a Mon Sep 17 00:00:00 2001 From: michbur Date: Wed, 14 Aug 2024 08:54:46 +0200 Subject: [PATCH 2/2] trying to fix validate motifs --- R/motifs.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/R/motifs.R b/R/motifs.R index 139798a..8cc4c5a 100644 --- a/R/motifs.R +++ b/R/motifs.R @@ -80,6 +80,10 @@ add_motifs <- function(motifs, sequence) { motifs_grid <- expand.grid(maximum_motifs_positions) motifs_grid <- motifs_grid[sample(1:nrow(motifs_grid)), , drop = FALSE] + if(any(motifs_grid < 1)) { + stop("Some of positions are invalid!") + } + for (i in 1:nrow(motifs_grid)) { list_of_masks <- list() injected_sequence <- sequence