Skip to content

Instantly share code, notes, and snippets.

@FranjoIM
Created April 8, 2020 04:23
Show Gist options
  • Save FranjoIM/e46bc53ffd33b9991e62cf7136f6e26a to your computer and use it in GitHub Desktop.
Save FranjoIM/e46bc53ffd33b9991e62cf7136f6e26a to your computer and use it in GitHub Desktop.
DNA Reverse Complement: This function takes a string-type variable containing DNA and it returns its reverse complement
# Load a library necessary to run this code
library(stringi)
# Define the reverse complement function
rev.comp <- function(DNASeq)
return(stri_reverse(chartr("acgtACGT", "tgcaTGCA", DNASeq)))
# Run the code on the dataframe called DF
DF$Seq <- ifelse (DF$Strand == c("-"), rev.comp(DF$Seq), DF$Seq)
library(plyr)
CombinedDF <- join(MainDF, LookUpDF, by = "Column")
heead(CombinedDF)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment