Skip to content

Instantly share code, notes, and snippets.

@timedreamer
Last active July 24, 2020 02:42
Show Gist options
  • Save timedreamer/9a662cfe28a259d02d99426e165a4374 to your computer and use it in GitHub Desktop.
Save timedreamer/9a662cfe28a259d02d99426e165a4374 to your computer and use it in GitHub Desktop.
Convert network precision score to the edge weight.
I used the precision curve only to decide the cutoff value. I chose a precision cutoff 0.2, then the correspondent normalized ranking is *~0.01*. The meaning of the normalized ranking is explained [here](https://github.com/takayasaito/precrec/issues/12).
Therefore, to calculate the **weight** value for precision 0.2, we got the following calculation: (rank-1)/(n-1) = 0.01. In this case, `n=nrow(dfg_ortho_label)`, so the rank is *649*. We went back to the *649* row of the `dfg_ortho_label`, the `weight` is 1.57. Therefore, we kept the edge that has weight higher than 1.57.
```{r, fig.width=5, fig.height=5, fig.align="center"}
scurve_os_b <- evalmod(scores = dfg_ortho_label$weight, labels = dfg_ortho_label$label,
mode = "basic")
sos_df_b <- fortify(scurve_os_b)
p2 <- ggplot(subset(sos_df_b, curvetype == "precision"), aes(x = x, y = y))+
geom_point(color = "blue", size = 0.4)+ ylim(0:1)
p2 + geom_hline(yintercept = 0.2, color = "black", linetype = "dashed") +
geom_vline(xintercept = 0.022, color = "black", linetype = "dashed") +
xlab("normalized rank") +
ylab("Precision") +
geom_vline(xintercept = 0.015, color = "black", linetype = "dashed")
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment