Skip to content

Instantly share code, notes, and snippets.

@sirusb
sirusb / Biostrings_Views.r
Last active August 29, 2015 14:13
Example of using Biostrings views
library(Biostrings)
library(BSgenome.Hsapiens.UCSC.hg19)
#نأخذ الكروموزوم 1 كمثال
Hsapiens$chr1
# 249250621-letter "DNAString" instance
#seq: NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN...NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
# لنفرض أننا مهتمين بسلسلة الجينات ABCA4, ACADM و GBA
genes <- Views(Hsapiens$chr1,
DNAs <- c("ACCT-NACG", "ACGTTCGA","TCACCGAGACTTACGAC")
dnaSet <- DNAStringSet(DNAs)
dnaSet
# A DNAStringSet instance of length 3
# width seq
#[1] 9 ACCT-NACG
#[2] 8 ACGTTCGA
#[3] 17 TCACCGAGACTTACGAC
#يمكن القيام بعمليات على مجموعة من السلاسل مع بعض
@sirusb
sirusb / Biostrings_access.r
Last active August 29, 2015 14:12
Biostrings basic access
ds <- DNAString("GCAAAGT-TT-C")
length(ds)
# [1] 12
ds[1:3]
# 3-letter "DNAString" instance
#seq: GCA
ds[3:1]
# 3-letter "DNAString" instance
@sirusb
sirusb / Biostring_classes.r
Last active August 29, 2015 14:12
Example of the basic Biostring classes
library(Biostrings)
bs <- BString("This is a normal string") # BString انشاء كائن
ds <- DNAString("GCAAAGT-TT-C") # DNAString انشاء كائن
rs <- RNAString("GCAAAGU-UU-C") # RNAString انشاء كائن
rs2 <- RNAString(ds) # RNAString إلى DNAString تحويل
aas <- AAString(ds) # AAString انشاء كائن
@sirusb
sirusb / gist:81f3f180b08a16a8ac2f
Last active December 26, 2015 02:39
This script is to read a CSV file that contain a list of genes in HGNC format in each column and will plot the GO enrichment analysis using DAVID webservice.
DoDAVIDGOAnnotation <-function(topics,pval=0.05,GOlimit=5){
clusters<-1:ncol(topics)
Groups<-c();
Annot<-c();
pvalue<-c();
counts<-c();
for(clus in clusters){
#Get the genes in that cluster
@sirusb
sirusb / gist:4761150
Last active December 12, 2015 10:39
These R code snippets are used to convert between Entrez and Ensembl IDs using biomart web-service. it just exploits the functionalities offered by the biomaRt package. The code is implemented to call the Biomart web-service each time. you can make it more general by calling the first four lines separatly and just passing the "hsp" variable to f…
#Usage example:
#EntrezID<-c("2114","9757","5886","9373","6921","4088","7006","6196","10054","10945")
#EnsemblID<-EntrezToEnsembl(EntrezID)
EntrezToEnsembl<-function(EntrezID){
require(biomaRt);
ensemble<-useMart("ensembl");
hsp<-useDataset(mart=ensemble,dataset="hsapiens_gene_ensembl");
ids<-getBM(filters= "entrezgene",
attributes= c("entrezgene","ensembl_gene_id", "external_gene_id","description"),