       (:group-votes conv))))
 
 
+(defn importance-metric
+  [A P S E]
+  (let [p (/ (+ P 1) (+ S 2))
+        a (/ (+ A 1) (+ S 2))]
+    (* (- 1 p) (+ E 1) a)))
+
+
+(defn cmnt-stats
+  [conv tid extremity]
+  (let [group-votes (:group-votes conv)
+        {:as total-votes :keys [A D S P]}
+        ;; reduce over votes per group, already aggregated
+        (reduce
+          (fn [votes [gid data]]
+            (let [{:as data :keys [A S D]} (get-in data [:votes tid])
+                  data (assoc data :P (+ (- S (+ A D))))]
+              ;; Add in each of the data's kv count pairs
+              (reduce
+                (fn [votes' [k v]]
+                  (update votes' k + v))
+                votes
+                data)))
+          {:A 0 :D 0 :S 0 :P 0}
+          group-votes)
+        importance
+        (importance-metric A P S extremity)
+        priority
+        (get-in conv [:comment-priorities tid])]
+    (log/spy
+      {:total-votes (str total-votes)
+       :priority priority
+       :importance importance
+       :fontSize (* priority 40)})))
+
+
 (defn comments-data
   [conv]
-  (map
-    (fn [tid extremity [x y]]
-      (merge
-        {:label tid
-         :x x
-         :y y
-         :extremity extremity
-         :type "comment"}
-        (cmnt-group-votes conv tid)))
-    (:tids conv)
-    (-> conv :pca :comment-extremity)
-    (-> conv :pca :comment-projection matrix/transpose)))
+  (->> 
+    (map
+      (fn [tid extremity [x y]]
+        (merge
+          {:tid tid
+           :label tid
+           :x x
+           :y y
+           :extremity extremity
+           :type "comment"}
+          (cmnt-group-votes conv tid)
+          (cmnt-stats conv tid extremity)))
+      (:tids conv)
+      (-> conv :pca :comment-extremity)
+      (-> conv :pca :comment-projection matrix/transpose))
+    (remove (comp (:mod-out conv) :tid))))
+
 
 (defn groups-data
   [conv]

           {:mark "text"
            :encoding {:x {:field "x"}
                       :y {:field "y"}
                       :text {:field "label"}}}]})

(defn p! [conv]
  (viz/p! (assoc conv-plot :data {:values (conv-data conv)})))

;; Test calls here
;(def plot-data
;  (conv-data conv))
;(def the-plot
;  (p! conv))





  ;(def zid 17175)
  ;(def zid 16703)
  ;(def zid 16906)
  ;(def zid 17890)
  (def zid 18115)
  (def args {:zid zid})

  (def conv
    (-> (load-conv args)
        (conv/conv-update [])))

  (def priority-plot (plot-priorities! conv :strict-mod true :exclude-meta true))
  (pp/pprint priority-plot)
  (publish-plot! "comments-buble-up.json" priority-plot)


  (->> (nm/get-matrix (:raw-rating-mat conv))
       matrix/shape)
  (sort (keys conv))
  ;(let [matrix (nm/get-matrix (:raw-rating-mat conv))]
    ;(->> matrix
         ;matrix/columns
         ;(map
           ;(fn [col]
             ;(let [seen (remove nil? col)
                   ;agree ()]
               ;#(/ % (-> matrix matrix/shape first))
               ;count
               ;double)))
         ;sort))

  ;; Look at profile output
  (sort-by (comp - second) @(:profile-data conv))
  (reduce + (map second @(:profile-data conv)))

  ;; Plot the conversation
  (p! conv)

  ;; Run correlation matrix
  ;(corr/default-tids conv)
