df_to_fasta: Fasta file creation from dataframe columns and/or vectors.

View source: R/df_to_fasta.R

df_to_fastaR Documentation

Fasta file creation from dataframe columns and/or vectors.

Description

Creates a fasta file from vectors of names and sequences.

Usage

df_to_fasta(
  sequence_name,
  sequence_strings,
  file_name = "sequences.fasta",
  output_dir = NULL,
  save_fasta = TRUE
)

Arguments

sequence_name

Vector containing the names for each sequence, usually a column from a data.frame. eg. df$sequence_name

sequence_strings

Vector containing the DNA or RNA or AA sequences, usually a column from a data.frame. eg. df$sequences

file_name

Output file name to be saved as a fasta file

output_dir

Output directory for the fasta file. Default is the working directory

save_fasta

Logical argument, TRUE or FALSE, to indicate if fasta files should be saved. Default is TRUE.

Value

Saves a fasta file in the desired location, and also returns the stringset as BStringSet if saved as an object.

Examples

## Example with vectors, default for save_fasta ir TRUE
df_to_fasta(
    sequence_name = c("myseq1", "myseq2"),
    sequence_strings = c("GATCGAT", "ATCGTAG"),
    file_name = "my_sequences.fasta",
    output_dir = "",
    save_fasta = FALSE
)

rodrigarc/RepertoiR documentation built on Aug. 14, 2024, 6:29 a.m.