Commit ba904f3b authored by smorabit's avatar smorabit
Browse files

fix igraph stuff

parent 9bf9ceb3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
Package: hdWGCNA
Title: hdWGCNA
Version: 0.2.18
Version: 0.2.19
Authors@R: c(
    person("Sam", "Morabito", , "smorabit@uci.edu", role = c("aut", "cre"),
           comment = c(ORCID = "0000-0002-7768-4856")),
+8 −0
Original line number Diff line number Diff line
# hdWGCNA 0.2.19 (2023-06-13)
## Added
- None.

## Changes
- Updated README to include publication, and fixed several igraph function calls.


# hdWGCNA 0.2.18 (2023-04-14)
## Added
- None.
+28 −29
Original line number Diff line number Diff line
@@ -383,7 +383,6 @@ ModuleCorrNetwork <- function(
  })) %>% as.data.frame



  # get correlation matrix
  cor_mat <- Hmisc::rcorr(as.matrix(MEs[,1:ncol(MEs)-1]))$r
  cor_mat[lower.tri(cor_mat)] <- NA
@@ -423,17 +422,17 @@ ModuleCorrNetwork <- function(
  e <-  get.edgelist(g, name=FALSE)
  # l <- igraph::layout_with_fr(
  #   g,
  #   weights=E(g)$value,
  #   coords = as.matrix(data.frame(x=V(g)$x, y=V(g)$y)),
  #   weights=igraph::E(g)$value,
  #   coords = as.matrix(data.frame(x=igraph::V(g)$x, y=igraph::V(g)$y)),
  #   niter=niter
  # )
  #
  l <- qgraph::qgraph.layout.fruchtermanreingold(
    e, vcount = vcount(g),
    weights=E(g)$value,
    weights=igraph::E(g)$value,
    repulse.rad=(vcount(g)),
    #cool.exp = 0.5,
    # init = as.matrix(data.frame(x=V(g)$x, y=V(g)$y)),
    # init = as.matrix(data.frame(x=igraph::V(g)$x, y=igraph::V(g)$y)),
    niter=niter,
    #max.delta = vcount(g)/2
  )
@@ -444,21 +443,21 @@ ModuleCorrNetwork <- function(
  temp <- ggplot(plot_df, aes(x=value, y=value, color=value)) +
    geom_point() + scale_color_gradient2(high='darkorchid1', mid='white', low='seagreen', midpoint=0)
  temp <- ggplot_build(temp)
  E(g)$color <- temp$data[[1]]$colour[1:nrow(cor_df)]
  igraph::E(g)$color <- temp$data[[1]]$colour[1:nrow(cor_df)]

  # label the vertices?
  if(label_vertices){labels <- V(g)$name} else{labels <- NA}
  if(label_vertices){labels <- igraph::V(g)$name} else{labels <- NA}

  # vertex_frame
  if(vertex_frame){frame_color <- 'black'} else{frame_color <- V(g)$color}
  if(vertex_frame){frame_color <- 'black'} else{frame_color <- igraph::V(g)$color}

  # plot the graph
  plot(
    g, layout=l,
    edge.color=E(g)$color,
    edge.color=igraph::E(g)$color,
    edge.curved=0,
    edge.width=abs(E(g)$value) * edge_scale,
    vertex.color=V(g)$color,
    edge.width=abs(igraph::E(g)$value) * edge_scale,
    vertex.color=igraph::V(g)$color,
    vertex.frame.color=frame_color,
    vertex.label=labels,
    vertex.label.family='Helvetica',
@@ -1082,16 +1081,16 @@ HubGeneNetworkPlot <- function(

  plot(
    g, layout=l,
    edge.color=adjustcolor(E(g)$color, alpha.f=edge.alpha),
    vertex.size=V(g)$size,
    edge.color=adjustcolor(igraph::E(g)$color, alpha.f=edge.alpha),
    vertex.size=igraph::V(g)$size,
    edge.curved=0,
    edge.width=0.5,
    vertex.color=V(g)$color,
    vertex.frame.color=V(g)$color,
    vertex.label=V(g)$label,
    vertex.color=igraph::V(g)$color,
    vertex.frame.color=igraph::V(g)$color,
    vertex.label=igraph::V(g)$label,
    vertex.label.family='Helvetica', #vertex.label.font=vertex_df$font,
    vertex.label.font = 3,
    vertex.label.color = V(g)$fontcolor,
    vertex.label.color = igraph::V(g)$fontcolor,
    vertex.label.cex=vertex.label.cex,
    ...
  )
@@ -1272,20 +1271,20 @@ ModuleUMAPPlot <- function(
  plot(
    g,
    layout=  as.matrix(selected_modules[,c('UMAP1', 'UMAP2')]),
    # edge.color=adjustcolor(E(g)$color, alpha.f=edge.alpha),
    edge.color=adjustcolor(E(g)$color_alpha, alpha.f=edge.alpha),
    vertex.size=V(g)$kME * 3,
    # edge.color=adjustcolor(igraph::E(g)$color, alpha.f=edge.alpha),
    edge.color=adjustcolor(igraph::E(g)$color_alpha, alpha.f=edge.alpha),
    vertex.size=igraph::V(g)$kME * 3,
    edge.curved=0,
    edge.width=0.5,
    vertex.color=V(g)$color,
    vertex.label=V(g)$label,
    vertex.color=igraph::V(g)$color,
    vertex.label=igraph::V(g)$label,
    vertex.label.dist=1.1,
    vertex.label.degree=-pi/4,
    vertex.label.family='Helvetica', #vertex.label.font=vertex_df$font,
    vertex.label.font = 3,
    vertex.label.color = V(g)$fontcolor,
    vertex.label.color = igraph::V(g)$fontcolor,
    vertex.label.cex=0,
    vertex.frame.color=V(g)$framecolor,
    vertex.frame.color=igraph::V(g)$framecolor,
    margin=0
  )

@@ -2160,18 +2159,18 @@ ModuleTFNetwork <- function(
    edge.width=1,
    vertex.color='grey',
    vertex.label='',
    edge.color=adjustcolor(E(g2)$color, alpha.f=edge.alpha),
    edge.color=adjustcolor(igraph::E(g2)$color, alpha.f=edge.alpha),
  )

  plot(
    g1,
    layout = as.matrix(node_df[,c('UMAP1', 'UMAP2')]),
    edge.color=adjustcolor(E(g1)$color),
    vertex.size=V(g1)$size * size.scale,
    edge.color=adjustcolor(igraph::E(g1)$color),
    vertex.size=igraph::V(g1)$size * size.scale,
    edge.curved=0,
    edge.width=edge_df$value*2,
    vertex.color=V(g1)$color,
    vertex.label=V(g1)$name,
    vertex.color=igraph::V(g1)$color,
    vertex.label=igraph::V(g1)$name,
    vertex.label.dist=1.1,
    vertex.label.degree=-pi/4,
    vertex.label.family='Helvetica',
+8 −7
Original line number Diff line number Diff line
@@ -16,15 +16,16 @@ provides context for these modules through various biological knowledge sources.
hdWGCNA requires data formatted as [Seurat](https://satijalab.org/seurat/index.html) objects,
one of the most ubiquitous formats for single-cell data. Check out the [hdWGCNA in single-cell data tutorial](https://smorabit.github.io/hdWGCNA/articles/basic_tutorial.html) or the [hdWGCNA in spatial transcriptomics data tutorial](https://smorabit.github.io/hdWGCNA/articles/ST_basics.html) to get started.

**Note:** hdWGCNA is under active development, so you may run into errors and small typos. We welcome users to
**Note about package development:** hdWGCNA is under active development, so you may run into errors and small typos. We welcome users to
write [GitHub issues](https://docs.github.com/en/issues/tracking-your-work-with-issues/creating-an-issue)
to report bugs, ask for help, and to request potential enhancements.

If you use hdWGCNA in your research, please cite the following papers in addition to the original WGCNA publication:
**Note about Seurat v5:** We plan to test the compatibility of hdWGCNA with[Seurat version 5](https://satijalab.org/seurat/articles/get_started_v5.html). with Seurat v5, but we have currently not updated hdWGCNA to work with Seurat v5. We strongly suggest using Seurat v4 at this time, or use v5 at your own risk.

* [Morabito et al. bioRxiv 2022](https://www.biorxiv.org/content/10.1101/2022.09.22.509094v1)
* [Morabito & Miyoshi et al. Nature Genetics 2021](https://doi.org/10.1038/s41588-021-00894-z)
If you use hdWGCNA in your research, please cite the following papers in addition to the original WGCNA publication:

* [Morabito et al., Cell Reports Methods (2023)](https://www.cell.com/cell-reports-methods/fulltext/S2667-2375(23)00127-3)
* [Morabito & Miyoshi et al., Nature Genetics (2021)](https://doi.org/10.1038/s41588-021-00894-z)


## Installation
@@ -43,7 +44,7 @@ conda activate hdWGCNA
Next, open up R and install the required dependencies:

* [Bioconductor](https://www.bioconductor.org/), an R-based software ecosystem for bioinformatics and biostatistics.
* [Seurat](https://satijalab.org/seurat/index.html), a general-purpose toolkit for single-cell data science.
* [Seurat](https://satijalab.org/seurat/index.html), a general-purpose toolkit for single-cell data science. We do not recommend using hdWGCNA with Seurat v5 at this time.
* [WGCNA](https://horvath.genetics.ucla.edu/html/CoexpressionNetwork/Rpackages/WGCNA/), a package for co-expression network analysis.
* [igraph](https://igraph.org/r/), a package for general network analysis and visualization.
* [devtools](https://devtools.r-lib.org/), a package for package development in R.
@@ -68,9 +69,9 @@ devtools::install_github('smorabit/hdWGCNA', ref='dev')

## Suggested Reading

Check out the hdWGCNA manuscript on bioRxiv, and our original description of applying WGCNA to single-nucleus RNA-seq data:
Check out the paper describing hdWGCNA, and our original description of applying WGCNA to single-nucleus RNA-seq data:

* [High dimensional co-expression networks enable discovery of transcriptomic drivers in complex biological systems](https://www.biorxiv.org/content/10.1101/2022.09.22.509094v1)
* [hdWGCNA identifies co-expression networks in high-dimensional transcriptomics data](https://www.cell.com/cell-reports-methods/fulltext/S2667-2375(23)00127-3)
* [Single-nucleus chromatin accessibility and transcriptomic characterization of Alzheimer’s disease](https://doi.org/10.1038/s41588-021-00894-z)


+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@
      </button>
      <span class="navbar-brand">
        <a class="navbar-link" href="https://smorabit.github.io/hdWGCNA/index.html">hdWGCNA</a>
        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="">0.2.18</span>
        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="">0.2.19</span>
      </span>
    </div>

Loading