<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 * Visualizing of genetic similarity with Lightning + GraphX *
Setup lightning
Step1:  Load structure similarity data
Public data from http
Step2:  Show the network (unlabeled)
Step3:  Show the network colored by degree
Step4:  Show the network colored by connected components
<ASSISTANT_TASK:>
Python Code:
%libraryDependencies += "org.viz.lightning" %% "lightning-scala" % "0.1.6"
%update
import org.viz.lightning._
import org.apache.spark.graphx._
val lgn = Lightning(host="https://lightning-spark-summit.herokuapp.com" )
lgn.enableNotebook()
Explanation: * Visualizing of genetic similarity with Lightning + GraphX *
Setup lightning
End of explanation
val source = "/Users/mathisonian/projects/spark-summit/notebooks/data/allen-connectivity.txt"
val g = GraphLoader.edgeListFile(sc, source)
Explanation: Load structure similarity data
Public data from http://www.brain-map.org/
End of explanation
val links = g.edges.collect().map(e => Array(e.srcId.toInt, e.dstId.toInt))
lgn.force(links)
Explanation: Show the network (unlabeled)
End of explanation
val links = g.edges.collect().map(e => Array(e.srcId.toInt, e.dstId.toInt))
val degrees = g.degrees.sortBy(_._1).collect().map(x => Math.log(x._2))
lgn.force(links, value=degrees, colormap="Lightning")
Explanation: Show the network colored by degree
End of explanation
val links = g.edges.collect().map(e => Array(e.srcId.toInt, e.dstId.toInt))
val connectedComponents = g.connectedComponents().vertices.sortBy(_._1).map(_._2.toInt).collect()
lgn.force(links, label=connectedComponents)
Explanation: Show the network colored by connected components
End of explanation
<END_TASK>