## load additional packages in this chunk
library(synaptome.db)
library(ggplot2)
knitr::opts_chunk$set(echo = TRUE)
gp<-findGeneByCompartmentPaperCnt(1)
papers <- getPapers()

Presynaptic

# presynaptic stats
presgp <- gp[gp$Localisation == "Presynaptic",]
svgp <- gp[gp$Localisation == "Synaptic_Vesicle",]
syngp <- gp[gp$Localisation == "Synaptosome",]
presg <- getGeneInfoByIDs(presgp$GeneID)
#mpres <- merge(presgp, presg, by = "GeneID")
mpres <- merge(presgp, presg, by = c("GeneID","Localisation"))
#mmpres <- mpres[, c(1,3,6, 10, 17, 18, 19)]
mmpres <- mpres[, c('GeneID','HumanEntrez.x','HumanName.x','Npmid','PaperPMID','Paper','Year')]
head(mmpres)

prespap <- papers[papers$Localisation == "Presynaptic",]
mmmpres <- mmpres[mmpres$PaperPMID %in% prespap$PaperPMID,]
table(mmmpres$Npmid)
mmmpres$found <- 0
for(i in 1:dim(mmmpres)[1]) {
    if (mmmpres$Npmid[i] == 1) {
        mmmpres$found[i] <- '1'
    } else if (mmmpres$Npmid[i] > 1 & mmmpres$Npmid[i] < 4) {
        mmmpres$found[i] <- '2-3'
    } else if (mmmpres$Npmid[i] >= 4 & mmmpres$Npmid[i] < 10) {
        mmmpres$found[i] <- '4-9'
    } else if (mmmpres$Npmid[i] >= 10) {
        mmmpres$found[i] <- '>10'
    }
}

mmmpres$found<- factor(mmmpres$found,levels = c('1','2-3','4-9','>10'),ordered=TRUE)
tp<-unique(mmmpres$Paper)
mmmpres$Paper<- factor(mmmpres$Paper,
                       levels =tp[order(as.numeric(sub('^[^0-9]+_([0-9]+)',
                                                      '\\1',tp)))],
                       ordered=TRUE)

ummpres<-unique(mmmpres[,c('GeneID','Paper','found')])
ggplot(ummpres) + geom_bar(aes(y = Paper, fill = found)) 

Postsynaptic

#postsynaptic stats

pstgp <- gp[gp$Localisation == "Postsynaptic",]
postg <- getGeneInfoByIDs(pstgp$GeneID)
#mpost <- merge(pstgp, postg, by = "GeneID")
mpost <- merge(pstgp, postg, by = c("GeneID","Localisation"))
#mmpost <- mpost[, c(1,3,6, 10, 17, 18, 19)]
mmpost <- mpost[, c('GeneID','HumanEntrez.x','HumanName.x','Npmid','PaperPMID','Paper','Year')]
postspap <- papers[papers$Localisation == "Postsynaptic",]
mmmpost <- mmpost[mmpost$PaperPMID %in% postspap$PaperPMID,]

table(mmmpost$Npmid)
mmmpost$found <- 0
for(i in 1:dim(mmmpost)[1]) {
    if (mmmpost$Npmid[i] == 1) {
        mmmpost$found[i] <- '1'
    } else if (mmmpost$Npmid[i] > 1 & mmmpost$Npmid[i] < 4) {
        mmmpost$found[i] <- '2-3'
    } else if (mmmpost$Npmid[i] >= 4 & mmmpost$Npmid[i] < 10) {
        mmmpost$found[i] <- '4-9'
    } else if (mmmpost$Npmid[i] >= 10) {
        mmmpost$found[i] <- '>10'
    }
}

mmmpost$found<- factor(mmmpost$found,levels = c('1','2-3','4-9','>10'),ordered=TRUE)
tp<-unique(mmmpost$Paper)
mmmpost$Paper<- factor(mmmpost$Paper,
                       levels =tp[order(as.numeric(sub('^[^0-9]+_([0-9]+)',
                                                      '\\1',tp)))],
                       ordered=TRUE)

ummpos<-unique(mmmpost[,c('GeneID','Paper','found')])
ggplot(ummpos) + geom_bar(aes(y = Paper, fill = found)) 

Synaptic Vesicle

#postsynaptic stats

svgp <- gp[gp$Localisation == "Synaptic_Vesicle",]
svg <- getGeneInfoByIDs(svgp$GeneID)
#mpost <- merge(pstgp, postg, by = "GeneID")
mpost <- merge(svgp, svg, by = c("GeneID","Localisation"))
mpost$Paper<-paste0(mpost$Paper,ifelse('FULL'==mpost$Dataset,'','_SVR'))
#mmpost <- mpost[, c(1,3,6, 10, 17, 18, 19)]
mmpost <- mpost[, c('GeneID','HumanEntrez.x','HumanName.x','Npmid','PaperPMID','Paper','Year')]
postspap <- papers[papers$Localisation == "Synaptic_Vesicle",]
mmmpost <- mmpost[mmpost$PaperPMID %in% postspap$PaperPMID,]

table(mmmpost$Npmid)
mmmpost$found <- 0
for(i in 1:dim(mmmpost)[1]) {
    if (mmmpost$Npmid[i] == 1) {
        mmmpost$found[i] <- '1'
    } else if (mmmpost$Npmid[i] > 1 & mmmpost$Npmid[i] < 4) {
        mmmpost$found[i] <- '2-3'
    } else if (mmmpost$Npmid[i] >= 4 & mmmpost$Npmid[i] < 10) {
        mmmpost$found[i] <- '4-9'
    } else if (mmmpost$Npmid[i] >= 10) {
        mmmpost$found[i] <- '>10'
    }
}

mmmpost$found<- factor(mmmpost$found,levels = c('1','2-3','4-9','>10'),
                       ordered=TRUE)
tp<-unique(mmmpost$Paper)
mmmpost$Paper<- factor(mmmpost$Paper,
                       levels =tp[order(as.numeric(sub('^[^0-9]+_([0-9]+)_?.*',
                                                       '\\1',tp)))],
                       ordered=TRUE)

ummpos<-unique(mmmpost[,c('GeneID','Paper','found')])
g<-ggplot(ummpos) + geom_bar(aes(y = Paper, fill = found)) 
g
mmmpost$found <- 0
for(i in 1:dim(mmmpost)[1]) {
    if (mmmpost$Npmid[i] == 1) {
        mmmpost$found[i] <- '1'
    } else if (mmmpost$Npmid[i] > 1 & mmmpost$Npmid[i] < 4) {
        mmmpost$found[i] <- '2-3'
    } else if (mmmpost$Npmid[i] >= 4 & mmmpost$Npmid[i] < 6) {
        mmmpost$found[i] <- '4-5'
    } else if (mmmpost$Npmid[i] >= 6) {
        mmmpost$found[i] <- '>6'
    }
}

mmmpost$found<- factor(mmmpost$found,levels = c('1','2-3','4-5','>6'),
                       ordered=TRUE)
tp<-unique(mmmpost$Paper)
mmmpost$Paper<- factor(mmmpost$Paper,
                       levels =tp[order(as.numeric(sub('^[^0-9]+_([0-9]+)_?.*',
                                                       '\\1',tp)))],
                       ordered=TRUE)

ummpos<-unique(mmmpost[,c('GeneID','Paper','found')])
g<-ggplot(ummpos) + geom_bar(aes(y = Paper, fill = found)) 
g

Brain region

#region stats
totg <- getGeneInfoByIDs(gp$GeneID)
#mtot <- merge(gp, totg, by = "GeneID")
mtot <- merge(gp, totg, by = c("GeneID","Localisation"))
#mmptot <- mtot[, c(1,3,6, 9, 10, 18, 21)]
mmptot <- mtot[, c('GeneID','HumanEntrez.x','HumanName.x','Localisation','Npmid','Paper','BrainRegion')]
head(mmptot)
#untot<-unique(mmptot[,c('GeneID','Paper','BrainRegion','Localisation.x')])
untot<-unique(mmptot[,c('GeneID','BrainRegion','Localisation')])
#names(untot)
#names(untot)[4] <- "Localisation"
ggplot(untot) + geom_bar(aes(y = BrainRegion, fill = Localisation)) + scale_fill_manual(values = c("#B99095","#B5E5CF","#FCB5AC", "#B99095"))

ggplot(untot) + geom_bar(aes(y = BrainRegion, fill = Localisation)) + scale_fill_manual(values = c("#3D5B59","#B5E5CF","#FCB5AC", "#B99095"))
table(untot$Localisation,untot$BrainRegion)-> m
as.data.frame(m)->udf
names(udf)<-c('Localisation','BrainRegion','value')
ggplot(udf, aes(fill=Localisation, y=value, x=BrainRegion)) +
geom_bar(position="dodge", stat="identity")+ scale_fill_manual(values = c("#3D5B59","#B5E5CF","#FCB5AC", "#B99095")) + theme(axis.text.x = element_text(face="plain", color="#993333", angle=45,vjust = 1,hjust=1,size = rel(1.5)))


lptolik/synaptome.db documentation built on Sept. 13, 2023, 2:50 p.m.