Skip to content

Instantly share code, notes, and snippets.

View Balharbi's full-sized avatar
💭
@mengyang2000 your coding style very intresting, mind if I ask abt repo DSS

Bader Alharbi Balharbi

💭
@mengyang2000 your coding style very intresting, mind if I ask abt repo DSS
  • Virginia
View GitHub Profile
@Balharbi
Balharbi / jaccard_genes_cluster.R
Created August 26, 2020 14:47 — forked from slavailn/jaccard_genes_cluster.R
Cluster sets of genes based on Jaccard distance (mostly stolen from Biostars post)
# test Jaccard
# Create a list gene sets
char1 <- c("gene1", "gene2", "gene5", "gene9", "gene10")
char2 <- c("gene2", "gene3", "gene5", "gene7", "gene10")
char3 <- c("gene7", "gene9", "gene10", "gene11", "gene12", "gene1")
lst <- list(char1, char2, char3)
# Function to calculate Jaccard distance
@Balharbi
Balharbi / Avoiding a loop.R
Created June 28, 2020 01:44 — forked from dsparks/Avoiding a loop.R
lapply() as an alternative to a multiply-nested loop
# Alternative to a doubly-nested loop
# Imagine I want to perform an operation on a data frame
# once for each combination of two variables, such as Country and Year
# I can do this with a nested loop, or I can do this with (among other
# things) lapply()
# Generate random data:
allCountries <- LETTERS[1:10]
allYears <- 1990:2012
@Balharbi
Balharbi / annotate_metilene_regions.R
Created March 7, 2020 17:10 — forked from slavailn/annotate_metilene_regions.R
annotate RRBS metilene regions
library(ChIPpeakAnno)
library(biomaRt)
library(genomation)
library(dplyr)
# Read in metilene results
res <- read.table("results_de_novo_all_10.txt", sep = "\t", header = T)
head(res)