Datasets
Datasets
Resource
PCA: https://youtu.be/hlDTniEz44E
PLA: https://youtu.be/erkU7yiApXQ
Hands-on R: https://www.w3schools.com/r/
R cook book: http://www.cookbook-r.com/
Rpubs: https://rpubs.com/
R-charts: https://r-charts.com/
R scripts
R script for graph
edist=function(x,y) {
sumd=0
for ( i in 1:length(x)) {
sumd=sumd+(x[i]-y[i])**2
}
sumd=sqrt(sumd)
return(as.numeric(sumd))
}
library(bio3d)
library(igraph)
pdb=read.pdb('1oltA.pdb')
calpha=pdb$atom[pdb$calpha, c("resno","x","y","z")]
head(calpha,n=2)
edges_list=c()
## find distances between all calpha atoms for network
nres=length(calpha$resno)
nres
#Lower triangle of matrix
for ( i in 1:nres){
X=c(calpha$x[i],calpha$y[i],calpha$z[i])
for ( j in 1:i){
if ( i == j ) { next }
Y=c(calpha$x[j],calpha$y[j],calpha$z[j])
dist=edist(X,Y)
if (dist <= 7) {
edges_list=c(edges_list,calpha$resno[i],calpha$resno[j])
}
}
}
g=make_graph(edges=edges_list,directed=F)
## Random network
ranGraph=erdos.renyi.game(5000,p=0.02,directed=FALSE)
ranGraph_deg=degree(ranGraph)
rdeg.dist=degree_distribution(ranGraph)
meanranK=mean(ranGraph_deg)
plot(rdeg.dist,pch=20,xlab="degree(k)",ylab="p(k)",las=1,main="Log plot",log="xy")
## Scale free network
gscale=barabasi.game(5000,power=1,m=3,directed=FALSE)
gscale_deg=degree(gscale)
gdeg.dist=degree_distribution(gscale)
meanK=mean(gscale_deg)
plot(gdeg.dist,pch=20,xlab="degree(k)",ylab="p(k)",las=1,main="Log plot",log="xy")