r - Using scatterplot3d to plot a sphere -


i have matrix of x,y,z coordinates of amino acids. plot protein in 3d space using following function:

make.plot <- function(position.matrix, center, radius){   scatterplot3d(x = position.matrix[,4], y = position.matrix[,5], z = position.matrix[,6], type = 'o', color = 'blue') } 

each row in position.matrix different amino acid. modify function if pass "center" correspond number in column 2 of position matrix (which lists amino acid numberings), radius, want sphere center @ amino acid.

for instance, if pass (position.matrix, 9, 3), want plot sphere of radius 3 around amino acid 9. have uploaded copy of position data here: http://temp-share.com/show/ygfhv2j7y

notice row count not canonical count residues skipped. pass "canonical" count...

thanks help!

here tested modification of code. adds length-2 size vector cex.symbols chosen adding 1 logical vector:

make.plot <- function(position.matrix, center, radius){     scatterplot3d(x = position.matrix[,4], y = position.matrix[,5],                    z = position.matrix[,6], type = 'o',            cex.symbols=c(1,radius)[1+(position.matrix[,2]==center)],  color = 'blue')           } 

enter image description here

i wonder if want rgl package. has shapes , interactive plotting environment. scatterplot3d make chose point red code:

myplot <- make.plot(position.matrix, 3, 9) myplot$points3d(position.matrix[3 , 4:6],  col="red", cex=10) 

i located code draw "parametric sphere" can adapted creating highlighting indicator:

myplot <- make.plot(position.matrix, 3, 9) a=seq(-pi,pi, length=10); myplot$points3d(x=2*c(rep(1, 10) %*% t(cos(a)))+position.matrix[3 , 4] ,   y=2*c(cos(a) %*% t(sin(a)))+position.matrix[3 , 5],  z=2*c(sin(a) %*% t(sin(a)))+position.matrix[3 , 6],  col="red", cex=.2) 

enter image description here


Comments

Popular posts from this blog

c++ - Compiling static TagLib 1.6.3 libraries for Windows -

PostgreSQL 9.x - pg_read_binary_file & inserting files into bytea -

Json.NET (Newtonsoft.Json) - Two 'properties' with same name? -