This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################## | |
## Create mappability file for reference genome ## | |
################################################## | |
## Thomas Girke | |
## Date: May 16, 2018 | |
## PeakSeq docs: | |
## https://github.com/gersteinlab/PeakSeq | |
## http://gensoft.pasteur.fr/docs/PeakSeq/1.1/PeakSeq.readme | |
## Note: mappability step should be skipped in newer version of PeakSeq |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x <- 1:12 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################################## | |
## Import of DrugBank Annotation Data ## | |
######################################## | |
## Function to import DrugBank XML to data.frame | |
## Last step gives error. To debug, the following function may help. | |
## Note, this functions needs some major speed improvements. Ideally, | |
## it should be replaced with a standard XML import method. | |
## (1) Download | |
## - download DrugBank XML (https://www.drugbank.ca/releases/latest) | |
## - name uncompressed file 'drugbank.xml' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##################################### | |
## Quality Trimming of FASTQ Reads ## | |
##################################### | |
## Author: Thomas Girke | |
## Last update: May 30, 2016 | |
## Usage of below function combined with preprocessReads form systemPipeR: | |
# qcTrim <- "qualityTrimming(fq, phred_cutoff=20, cutoff_occurrences=1, N_cutoff=1, minreadlength=100)" | |
# preprocessReads(args=args, Fct=qcTrim, batchsize=100000, overwrite=TRUE, compress=TRUE) | |
## Arguments: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################ | |
## appendCounter Function ## | |
############################ | |
## Author: Thomas Girke | |
## Last update: 04-Oct-15 | |
## Function to append occurrence counter to entries in character | |
## vector and return the results as named vector where the | |
## original data are in the same order in the data slot | |
## and the counting result in the name slot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################# | |
## Source R code from Gist ## | |
############################# | |
## Display code snippet as raw by pressing Raw button on top right corner of Gist | |
## Save URL in address bar of browser | |
# library(RCurl) | |
## (a) Source specific commit of code | |
# source(textConnection(getURL("https://gist.githubusercontent.com/tgirke/c26daac0f647f1732a58/raw/521292eca2d4daeab8911df2552f0c55b0e58e6b/Source_Gist_in_R"))) | |
## (b) Source latest version of code (delete commit ID in URL after .../raw/...) | |
# source(textConnection(getURL("https://gist.githubusercontent.com/tgirke/c26daac0f647f1732a58/raw/Source_Gist_in_R"))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my_frame[!duplicated(my_frame[,2]),] # Removes rows with duplicated values in selected column. | |
my_frame[my_frame$y2 > my_frame$y3,] # Prints all rows of data frame where values of col1 > col2. Comparison operators are: == (equal), != (not equal), >= (greater than or equal), etc. Logical operators are & (and), | (or) and ! (not). | |
x <- 0.5:10; x[x<1.0] <- -1/x[x<1.0] # Replaces all values in vector or data frame that are below 1 with their reciprocal value. | |
x <-data.frame(month=month.abb[1:12], AB=LETTERS[1:2], no1=1:48, no2=1:24); x[x$month == "Apr" & (x$no1 == x$no2 | x$no1 > x$no2),] # Prints all records of frame 'x' that contain 'Apr' AND have equal values in columns 'no1' and 'no2' OR have greater values in column 'no1'. | |
x[x[,1] %in% c("Jun", "Aug"),] # Retrieves rows with column matches specified in a query vector. | |
x[c(grep("\\d{2}", as.character(x$no1), perl = TRUE)),] # Possibility to print out all rows of a data frame where a regular expression matches (here all double digit values in col 'no1'). | |
x[c(g |