getEdgeWeightsG: getEdgeWeightsG

Description Usage Arguments Value Note Author(s) Examples

View source: R/SCRNA.R

Description

This functions takes in a functional module from scPPIN and a countTable for gene reads as a data frame and computes the edge weight for each connection in the functional module and returns a network data frame with edge weights included. Used for creating Cytoscape graphs.

Usage

1
getEdgeWeightsG(FM, countTable)

Arguments

FM

A scPPIN object that is returned from the function getFM. Used here to generate the network

countTable

A data frame containing counts of gene expression for different cell barcodes. Used here to generate edge weights

Value

returns a functional Modeule (igraph) with weight attribute set for edges based on spearman's correlation

Note

Called by getCyGraphs

Author(s)

Matt Heffernan, University of Illinois at Chicago

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

getEdgeWeightsG(FM=FM0, countTable=countTable)

## The function is currently defined as
function(FM, countTable)
{
  network <- as.data.frame(get.edgelist(FM))
  
  nEdges <- nrow(network)
  i=1
  while(i <= nEdges)
  {
    G1 = network[i,1]
    G2 = network[i,2]
    G1C <- countTable[G1,]
    G2C <- countTable[G2,]
    corr <- unname(cor.test(G1C,G2C,method="spearman", exact=FALSE)$estimate)
    FM <- set_edge_attr(FM, "weight", index = E(FM, P = c(G1,G2),directed = FALSE), value = corr)
    i = i+1
  }
  return(FM)
}

mheffe3/SCNVC documentation built on Dec. 21, 2021, 5:52 p.m.