Title: | Bioinformatics Genetic Algorithm (BioGA) |
---|---|
Description: | Genetic algorithm are a class of optimization algorithms inspired by the process of natural selection and genetics. This package allows users to analyze and optimize high throughput genomic data using genetic algorithms. The functions provided are implemented in C++ for improved speed and efficiency, with an easy-to-use interface for use within R. |
Authors: | Dany Mukesha [aut, cre] |
Maintainer: | Dany Mukesha <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.1.0 |
Built: | 2024-11-29 04:10:35 UTC |
Source: | https://github.com/bioc/BioGA |
Function to perform crossover between selected individuals
crossover_cpp(selected_parents, offspring_size)
crossover_cpp(selected_parents, offspring_size)
selected_parents |
Numeric matrix representing the selected individuals. |
offspring_size |
Number of offspring to generate. |
Numeric matrix representing the offspring.
# example of usage genomic_data <- matrix(rnorm(100), nrow = 10, ncol = 10) population <- BioGA::initialize_population_cpp(genomic_data, population_size = 5) fitness <- BioGA::evaluate_fitness_cpp(genomic_data, population) selected_parents <- BioGA::selection_cpp(population, fitness, num_parents = 2) BioGA::crossover_cpp(selected_parents, offspring_size = 2)
# example of usage genomic_data <- matrix(rnorm(100), nrow = 10, ncol = 10) population <- BioGA::initialize_population_cpp(genomic_data, population_size = 5) fitness <- BioGA::evaluate_fitness_cpp(genomic_data, population) selected_parents <- BioGA::selection_cpp(population, fitness, num_parents = 2) BioGA::crossover_cpp(selected_parents, offspring_size = 2)
Function to evaluate fitness using genomic data
evaluate_fitness_cpp(genomic_data, population)
evaluate_fitness_cpp(genomic_data, population)
genomic_data |
Numeric matrix of genomic data where rows represent genes/features and columns represent samples. |
population |
Numeric matrix representing the population of individuals. |
Numeric vector of fitness scores for each individual.
# example of usage genomic_data <- matrix(rnorm(100), nrow = 10, ncol = 10) population <- BioGA::initialize_population_cpp(genomic_data, population_size = 5) BioGA::evaluate_fitness_cpp(genomic_data, population)
# example of usage genomic_data <- matrix(rnorm(100), nrow = 10, ncol = 10) population <- BioGA::initialize_population_cpp(genomic_data, population_size = 5) BioGA::evaluate_fitness_cpp(genomic_data, population)
Function to initialize the population from genomic data
initialize_population_cpp(genomic_data, population_size)
initialize_population_cpp(genomic_data, population_size)
genomic_data |
Numeric matrix of genomic data where rows represent genes/features and columns represent samples. |
population_size |
Number of individuals in the population. |
Numeric matrix representing the initialized population.
# example of usage genomic_data <- matrix(rnorm(100), nrow = 10, ncol = 10) BioGA::initialize_population_cpp(genomic_data, population_size = 5)
# example of usage genomic_data <- matrix(rnorm(100), nrow = 10, ncol = 10) BioGA::initialize_population_cpp(genomic_data, population_size = 5)
Function to mutate the offspring
mutation_cpp(offspring, mutation_rate)
mutation_cpp(offspring, mutation_rate)
offspring |
Numeric matrix representing the offspring. |
mutation_rate |
Probability of mutation for each individual. |
Numeric matrix representing the mutated offspring.
# example of usage genomic_data <- matrix(rnorm(100), nrow = 10, ncol = 10) population <- BioGA::initialize_population_cpp(genomic_data, population_size = 5) fitness <- BioGA::evaluate_fitness_cpp(genomic_data, population) selected_parents <- BioGA::selection_cpp(population, fitness, num_parents = 2) offspring <- BioGA::crossover_cpp(selected_parents, offspring_size = 2) BioGA::mutation_cpp(offspring, mutation_rate = 0)
# example of usage genomic_data <- matrix(rnorm(100), nrow = 10, ncol = 10) population <- BioGA::initialize_population_cpp(genomic_data, population_size = 5) fitness <- BioGA::evaluate_fitness_cpp(genomic_data, population) selected_parents <- BioGA::selection_cpp(population, fitness, num_parents = 2) offspring <- BioGA::crossover_cpp(selected_parents, offspring_size = 2) BioGA::mutation_cpp(offspring, mutation_rate = 0)
Plot the fitness values of the population over generations.
plot_fitness(fitness_values)
plot_fitness(fitness_values)
fitness_values |
A numeric vector containing fitness values. |
Plot of fitness
# example of usage fitness_values <- c(10, 8, 6, 4, 2) plot_fitness(fitness_values)
# example of usage fitness_values <- c(10, 8, 6, 4, 2) plot_fitness(fitness_values)
Plot the change in fitness values over generations.
plot_fitness_history(fitness_history)
plot_fitness_history(fitness_history)
fitness_history |
A list containing fitness values for each generation. |
Plot of fitness history
# example of usage fitness_history <- list(c(10, 8, 6, 4, 2), c(9, 7, 5, 3, 1)) plot_fitness_history(fitness_history)
# example of usage fitness_history <- list(c(10, 8, 6, 4, 2), c(9, 7, 5, 3, 1)) plot_fitness_history(fitness_history)
Plot the distribution of individuals in the population.
plot_population(population)
plot_population(population)
population |
A numeric matrix containing the population data. |
Plot of population
# example of usage population <- matrix(runif(100), nrow = 10, ncol = 10) plot_population(population)
# example of usage population <- matrix(runif(100), nrow = 10, ncol = 10) plot_population(population)
Replace non-selected individuals in the population
replacement_cpp(population, offspring, num_to_replace)
replacement_cpp(population, offspring, num_to_replace)
population |
Numeric matrix representing the population of individuals. |
offspring |
Numeric matrix representing the offspring. |
num_to_replace |
Number of individuals to replace. |
Numeric matrix representing the updated population.
# example of usage genomic_data <- matrix(rnorm(100), nrow = 10, ncol = 10) population <- BioGA::initialize_population_cpp(genomic_data, population_size = 5) fitness <- BioGA::evaluate_fitness_cpp(genomic_data, population) selected_parents <- BioGA::selection_cpp(population, fitness, num_parents = 2) offspring <- BioGA::crossover_cpp(selected_parents, offspring_size = 2) mutated_offspring <- BioGA::mutation_cpp(offspring, mutation_rate = 0) BioGA::replacement_cpp(population, mutated_offspring, num_to_replace = 1)
# example of usage genomic_data <- matrix(rnorm(100), nrow = 10, ncol = 10) population <- BioGA::initialize_population_cpp(genomic_data, population_size = 5) fitness <- BioGA::evaluate_fitness_cpp(genomic_data, population) selected_parents <- BioGA::selection_cpp(population, fitness, num_parents = 2) offspring <- BioGA::crossover_cpp(selected_parents, offspring_size = 2) mutated_offspring <- BioGA::mutation_cpp(offspring, mutation_rate = 0) BioGA::replacement_cpp(population, mutated_offspring, num_to_replace = 1)
Function to select individuals based on fitness scores
selection_cpp(population, fitness, num_parents)
selection_cpp(population, fitness, num_parents)
population |
Numeric matrix representing the population of individuals. |
fitness |
Numeric vector of fitness scores for each individual. |
num_parents |
Number of individuals to select. |
Numeric matrix representing the selected individuals.
# example of usage genomic_data <- matrix(rnorm(100), nrow = 10, ncol = 10) population <- BioGA::initialize_population_cpp(genomic_data, population_size = 5) fitness <- BioGA::evaluate_fitness_cpp(genomic_data, population) BioGA::selection_cpp(population, fitness, num_parents = 2)
# example of usage genomic_data <- matrix(rnorm(100), nrow = 10, ncol = 10) population <- BioGA::initialize_population_cpp(genomic_data, population_size = 5) fitness <- BioGA::evaluate_fitness_cpp(genomic_data, population) BioGA::selection_cpp(population, fitness, num_parents = 2)