Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question not Issue #46

Open
marjanUofT opened this issue Sep 6, 2024 · 2 comments
Open

Question not Issue #46

marjanUofT opened this issue Sep 6, 2024 · 2 comments

Comments

@marjanUofT
Copy link

The task is to generate new sequences by introducing a random number of mutations at random positions within a specific range of positions, such as [29, 110).

I have the wild-type (WT) sequences, and I need to:

Apply a random number of mutations.
Mutate random positions within the defined range.
I am unsure if any of the available models can achieve this directly. If no suitable model exists, I can implement a method to generate mutations at random positions and then pass each mutated sequence to a model.

The goal is to generate at least 1,000 new sequences.

@yangkky
Copy link
Collaborator

yangkky commented Sep 7, 2024 via email

@marjanUofT
Copy link
Author

marjanUofT commented Sep 8, 2024

Thank you, @yangkky, for your quick response. Below is the code for generating mutation lists using the Poisson distribution and applying the "OA_DM_38M" model. This should help anyone looking to achieve similar results:

def generate_mutation_lists(num_lists=1000, mean_mutations=15, min_pos=21, max_pos=110):
    all_lists = []

    for _ in range(num_lists):
        num_mutations = np.random.poisson(mean_mutations)

        ends_list = np.random.randint(min_pos, max_pos + 1, num_mutations)
        ends_list.sort()  # Sort the end positions

        start_list = ends_list - 1

        start_list = np.clip(start_list, min_pos, max_pos)

        all_lists.append((start_list.tolist(), ends_list.tolist()))

    return all_lists
 

 
mutation_lists = generate_mutation_lists()  # This should be the result of the function you previously ran

total_num_gen_seqs = 1000
generated_sequences = {}

for idx, (start_ids, end_ids) in enumerate(mutation_lists):
    if idx >= total_num_gen_seqs:
        break
    start_ids = [start_ids]
    end_ids = [end_ids]

    masked_sequences = mask_sequences(sequences, start_ids, end_ids)

    tokenizer = tokenizer
    tokenized_sequences = tokenize_sequences(masked_sequences, tokenizer, device)

    new_sequences = generate_unique_sequences(model, tokenized_sequences, start_ids, end_ids, sequences, tokenizer, num_gen_seqs = 1)

    generated_sequences[idx] = new_sequences

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants