Title: | Network Seriation And Modularization |
---|---|
Description: | The NetSAM (Network Seriation and Modularization) package takes an edge-list representation of a weighted or unweighted network as an input, performs network seriation and modularization analysis, and generates as files that can be used as an input for the one-dimensional network visualization tool NetGestalt (http://www.netgestalt.org) or other network analysis. The NetSAM package can also generate correlation network (e.g. co-expression network) based on the input matrix data, perform seriation and modularization analysis for the correlation network and calculate the associations between the sample features and modules or identify the associated GO terms for the modules. |
Authors: | Jing Wang <[email protected]> |
Maintainer: | Zhiao Shi <[email protected]> |
License: | LGPL |
Version: | 1.47.0 |
Built: | 2024-10-30 08:30:24 UTC |
Source: | https://github.com/bioc/NetSAM |
The NetSAM (Network Seriation and Modularization) package takes an edge-list representation of a weighted or unweighted network as an input, performs network seriation and modularization analysis, and generates as files that can be used as an input for the one-dimensional network visualization tool NetGestalt (http://www.netgestalt.org) or other network analysis. Meanwhile, the NetSAM package can also generate correlation network (e.g. co-expression network) based on the input matrix data and then perform seriation and modularization analysis for correlation network.
Package: | NetSAM |
Type: | Package |
Version: | 1.31.1 |
Date: | 2021-05-15 |
License: | LGPL |
LazyLoad: | yes |
Jing Wang Maintainer: Zhiao Shi <[email protected]>
NetGestalt: integrating multidimensional omics data over biological networks. Nature Methods 10, 597-598 (2013).
To increase robustness against errors in data, the consensusNet function uses a bootstrapping procedure to construct a coexpression network.
consensusNet(data, organism="hsapiens",bootstrapNum=100, naPer=0.5, meanPer=0.8,varPer=0.8,method="rank_unsig",value=3/1000,pth=1e-6, nMatNet=2, nThreads=4)
consensusNet(data, organism="hsapiens",bootstrapNum=100, naPer=0.5, meanPer=0.8,varPer=0.8,method="rank_unsig",value=3/1000,pth=1e-6, nMatNet=2, nThreads=4)
data |
|
organism |
The organism of the input data. Currently, the package supports the following nine organisms: hsapiens, mmusculus, rnorvegicus, drerio, celegans, scerevisiae, cfamiliaris, dmelanogaster and athaliana. The default is "hsapiens". |
bootstrapNum |
Number of bootstrap data sets generated. Default is 100. |
naPer |
To remove ids with missing values in most of samples, the function calculates the percentage of missing values in all samples for each id and removes ids with over |
meanPer |
To remove ids with low values, the function calculates the mean of values for each id in all samples and remains top |
varPer |
Based on the remaining ids filtered by |
method |
Method used for constructing correlation network with |
value |
The corresponding value set for |
pth |
p-value threshold for including an edge. Default is 1.0e-6. |
nMatNet |
The number of concurrent running MatNet processes, default is 2. |
nThreads |
consensusNet function supports parallel computing based on multiple cores. The default is 4. |
Jing Wang
inputMatDir <- system.file("extdata","exampleExpressionData.cct",package="NetSAM") data <- read.table(inputMatDir, header=TRUE, row.names=1, stringsAsFactors=FALSE) net <- consensusNet(data, organism="hsapiens",bootstrapNum=10, naPer=0.5, meanPer=0.8,varPer=0.8,method="rank_unsig",value=3/1000,pth=1e-6, nMatNet=2, nThreads=4)
inputMatDir <- system.file("extdata","exampleExpressionData.cct",package="NetSAM") data <- read.table(inputMatDir, header=TRUE, row.names=1, stringsAsFactors=FALSE) net <- consensusNet(data, organism="hsapiens",bootstrapNum=10, naPer=0.5, meanPer=0.8,varPer=0.8,method="rank_unsig",value=3/1000,pth=1e-6, nMatNet=2, nThreads=4)
The featureAssociation function will calculate the associations between the sample features in the input annotation data and the modules identified by NetSAM or MatSAM function.
featureAssociation(inputMat, sampleAnn, NetSAMOutput, outputHtmlFile, CONMethod="spearman", CATMethod="kruskal", BINMethod="ranktest", fdrmethod="BH",pth=0.05,collapse_mode="maxSD")
featureAssociation(inputMat, sampleAnn, NetSAMOutput, outputHtmlFile, CONMethod="spearman", CATMethod="kruskal", BINMethod="ranktest", fdrmethod="BH",pth=0.05,collapse_mode="maxSD")
inputMat |
|
sampleAnn |
|
NetSAMOutput |
The list object outputted from NetSAM or MatSAM. |
outputHtmlFile |
The output directory of the HTML file. |
CONMethod |
The method to calculate the associations between modules and continuous features. The function provides two methods: "spearman" and "pearson" and the default is "spearman". |
CATMethod |
The method to calculate the associations between modules and category features. The function provides two methods: "anova" and "kruskal" and the default is "kruskal". |
BINMethod |
The method to calculate the associations between modules and binary features. The function provides two methods: "test" and "rankest" and the default is "rankest". |
fdrmethod |
The FDR method for identifying the significantly associated GO terms. The default is "BH". |
pth |
The threshold of the p values to identify the significant associations. |
collapse_mode |
The method to collapse duplicate ids. "mean", "median", "maxSD", "maxIQR", "max" and "min" represent the mean, median, max standard deviation, max interquartile range, maximum and minimum of values for ids in each sample. The default is "maxSD". |
The function will output a data.frame object and a HTML file to show the significant associations.
Jing Wang
inputMatDir <- system.file("extdata","exampleExpressionData.cct",package="NetSAM") sampleAnnDir <- system.file("extdata","sampleAnnotation.tsi",package="NetSAM") data(NetSAMOutput_Example) outputHtmlFile <- paste(getwd(),"/featureAsso_HTML",sep="") featureAsso <- featureAssociation(inputMat= inputMatDir, sampleAnn=sampleAnnDir, NetSAMOutput=netsam_output, outputHtmlFile=outputHtmlFile, CONMethod="spearman", CATMethod="kruskal", BINMethod="ranktest", fdrmethod="BH",pth=0.05,collapse_mode="maxSD")
inputMatDir <- system.file("extdata","exampleExpressionData.cct",package="NetSAM") sampleAnnDir <- system.file("extdata","sampleAnnotation.tsi",package="NetSAM") data(NetSAMOutput_Example) outputHtmlFile <- paste(getwd(),"/featureAsso_HTML",sep="") featureAsso <- featureAssociation(inputMat= inputMatDir, sampleAnn=sampleAnnDir, NetSAMOutput=netsam_output, outputHtmlFile=outputHtmlFile, CONMethod="spearman", CATMethod="kruskal", BINMethod="ranktest", fdrmethod="BH",pth=0.05,collapse_mode="maxSD")
The GOAssociation function will identify the associated GO terms for each module from the NetSAM or MatSAM function.
GOAssociation(NetSAMOutput, outputHtmlFile, organism, outputType, fdrmethod, fdrth, topNum)
GOAssociation(NetSAMOutput, outputHtmlFile, organism, outputType, fdrmethod, fdrth, topNum)
NetSAMOutput |
The list object outputted from the NetSAM or MatSAM function. |
outputHtmlFile |
The output directory of the HTML file. |
organism |
The organism of the input data matrix that has been used to identify the modules. Currently, the package supports the following nine organisms: hsapiens, mmusculus, rnorvegicus, drerio, celegans, scerevisiae, cfamiliaris, dmelanogaster and athaliana. The default is "hsapiens". |
outputType |
The function supports two types of output results. 1. "significant" represents all associated GO terms should be significant under a certain FDR threshold; 2. "top" represents the function first sorts all GO terms based on their hypergenometric test p values and then selects top GO terms as the associated terms. The default is "significant". |
fdrmethod |
The FDR method for identifying the significantly associated GO terms. The default is "BH". |
fdrth |
The FDR threshold. |
topNum |
The number of the selected top GO terms. |
The function will output a data.frame object and a HTML file to show the associated GO terms for each module.
Jing Wang
data(NetSAMOutput_Example) outputHtmlFile <- paste(getwd(),"/GOAsso_HTML",sep="") GOAsso <- GOAssociation(NetSAMOutput=netsam_output, outputHtmlFile=outputHtmlFile, organism="hsapiens", fdrmethod="BH", fdrth=0.05, topNum=5)
data(NetSAMOutput_Example) outputHtmlFile <- paste(getwd(),"/GOAsso_HTML",sep="") GOAsso <- GOAssociation(NetSAMOutput=netsam_output, outputHtmlFile=outputHtmlFile, organism="hsapiens", fdrmethod="BH", fdrth=0.05, topNum=5)
The mapToSymbol function can transform other ids from a gene list, network, matrix, sbt file or sct file to gene symbols.
mapToSymbol(inputData, organism="hsapiens", inputType="genelist", idType="auto", edgeType="unweighted", collapse_mode="maxSD", is_outputFile=FALSE, outputFileName="", verbose=TRUE)
mapToSymbol(inputData, organism="hsapiens", inputType="genelist", idType="auto", edgeType="unweighted", collapse_mode="maxSD", is_outputFile=FALSE, outputFileName="", verbose=TRUE)
inputData |
mapToSymbol function supports five different types of data: "genelist", "network", "matrix", "sbt" and "sct".
For "genelist" type, |
organism |
The organism of the input data. Currently, the package supports the following nine organisms: hsapiens, mmusculus, rnorvegicus, drerio, celegans, scerevisiae, cfamiliaris, dmelanogaster and athaliana. The default is "hsapiens". |
inputType |
The type of the input data. see detail information in |
idType |
The id type of the ids in the input data. MatSAM will use BiomaRt package to transform the input ids to gene symbols based on |
edgeType |
The type of the input network: "weighted" or "unweighted". |
collapse_mode |
The method to collapse duplicate ids. "mean", "median", "maxSD", "maxIQR", "max" and "min" represent the mean, median, max standard deviation, max interquartile range, maximum and minimum of values for ids in each sample. The default is "maxSD". For SCT file, we suggest to use "max" or "min" to collapse duplicate ids in the statistic data. |
is_outputFile |
If |
outputFileName |
The output file name. |
verbose |
Report the extra information on progress. The default is TRUE. |
Jing Wang
###transform ids from a gene list to gene symbols### geneListDir <- system.file("extdata","exampleGeneList.txt",package="NetSAM") geneList <- read.table(geneListDir,header=FALSE,sep="\t",stringsAsFactors=FALSE) geneList <- as.vector(as.matrix(geneList)) geneList_symbol <- mapToSymbol(inputData=geneList, organism="hsapiens", inputType="genelist",idType="affy_hg_u133_plus_2") ###transform ids in the input network to gene symbols### inputNetwork <- system.file("extdata","exampleNetwork_nonsymbol.net",package="NetSAM") network_symbol <- mapToSymbol(inputData=inputNetwork,organism="hsapiens",inputType="network",idType="entrezgene_id",edgeType="unweighted") ###transform ids in the input matrix to gene symbols### inputMatDir <- system.file("extdata","exampleExpressionData_nonsymbol.cct",package="NetSAM") matrix_symbol <- mapToSymbol(inputData=inputMatDir,organism="hsapiens",inputType="matrix",idType="affy_hg_u133_plus_2",collapse_mode="maxSD") ###transform ids in the sbt file to gene symbols### inputSBTDir <- system.file("extdata","exampleSBT.sbt",package="NetSAM") sbt_symbol <- mapToSymbol(inputData= inputSBTDir,organism="hsapiens",inputType="sbt",idType="affy_hg_u133_plus_2") ###transform ids in the sct file to gene symbols### inputSCTDir <- system.file("extdata","exampleSCT.sct",package="NetSAM") sct_symbol <- mapToSymbol(inputData= inputSCTDir,organism="hsapiens",inputType="sct",idType="affy_hg_u133_plus_2",collapse_mode="min")
###transform ids from a gene list to gene symbols### geneListDir <- system.file("extdata","exampleGeneList.txt",package="NetSAM") geneList <- read.table(geneListDir,header=FALSE,sep="\t",stringsAsFactors=FALSE) geneList <- as.vector(as.matrix(geneList)) geneList_symbol <- mapToSymbol(inputData=geneList, organism="hsapiens", inputType="genelist",idType="affy_hg_u133_plus_2") ###transform ids in the input network to gene symbols### inputNetwork <- system.file("extdata","exampleNetwork_nonsymbol.net",package="NetSAM") network_symbol <- mapToSymbol(inputData=inputNetwork,organism="hsapiens",inputType="network",idType="entrezgene_id",edgeType="unweighted") ###transform ids in the input matrix to gene symbols### inputMatDir <- system.file("extdata","exampleExpressionData_nonsymbol.cct",package="NetSAM") matrix_symbol <- mapToSymbol(inputData=inputMatDir,organism="hsapiens",inputType="matrix",idType="affy_hg_u133_plus_2",collapse_mode="maxSD") ###transform ids in the sbt file to gene symbols### inputSBTDir <- system.file("extdata","exampleSBT.sbt",package="NetSAM") sbt_symbol <- mapToSymbol(inputData= inputSBTDir,organism="hsapiens",inputType="sbt",idType="affy_hg_u133_plus_2") ###transform ids in the sct file to gene symbols### inputSCTDir <- system.file("extdata","exampleSCT.sct",package="NetSAM") sct_symbol <- mapToSymbol(inputData= inputSCTDir,organism="hsapiens",inputType="sct",idType="affy_hg_u133_plus_2",collapse_mode="min")
The MatNet function can use one of three different methods to construct correlation network based on the input data matrix. The output correlation network can be used as an input of NetSAM function to identify hierarchical modules.
MatNet(inputMat, collapse_mode="maxSD", naPer=0.7, meanPer=0.8, varPer=0.8, corrType="spearman", matNetMethod="rank", valueThr=0.5, rankBest=0.003, networkType="signed", netFDRMethod="BH", netFDRThr=0.05, idNumThr=(-1),nThreads=3)
MatNet(inputMat, collapse_mode="maxSD", naPer=0.7, meanPer=0.8, varPer=0.8, corrType="spearman", matNetMethod="rank", valueThr=0.5, rankBest=0.003, networkType="signed", netFDRMethod="BH", netFDRThr=0.05, idNumThr=(-1),nThreads=3)
inputMat |
|
collapse_mode |
If the input matrix data contains the duplicate ids, the function will collapse duplicate ids based on the |
naPer |
To remove ids with missing values in most of samples, the function calculates the percentage of missing values in all samples for each id and removes ids with over |
meanPer |
To remove ids with low values, the function calculates the mean of values for each id in all samples and remains top |
varPer |
Based on the remained ids filtered by |
corrType |
The method to calculate correlation coefficient for each pair of ids. The function supports "spearman" (default) or "pearson" method. |
matNetMethod |
MatNet function supports three methods to construct correlation network: "value", "rank" and "directed". 1. "value" method: the correlation network only remains id pairs with correlations over cutoff threshold |
valueThr |
Correlation cutoff threshold for "value" method. The default is 0.5. |
rankBest |
The percentage of ids that are most similar to one id for "rank" method. The default is 0.003 which means the "rank" method will select top 30 most similar ids for each id if the number of ids in the matrix is 10,000. |
networkType |
If |
netFDRMethod |
p value adjustment methods for "rank" and "directed" methods. The default is "BH". |
netFDRThr |
fdr threshold for identifying significant pairs for "rank" and "directed" methods. The default is 0.05 |
idNumThr |
If the matrix contains too many ids, it will take a long time and use a lot of memory to identify the modules. Thus, the function provides the option to set the threshold of number of ids for further analysis. After filtering by meanPer and varPer, if the number of ids is still larger than |
nThreads |
MatNet function supports parallel computing based on multiple cores. The default is 3. |
For data with missing values, the function will take longer time to calculate correlation between each pair of ids than data without missing value.
Jing Wang
inputMatDir <- system.file("extdata","exampleExpressionData.cct",package="NetSAM") matNetwork <- MatNet(inputMat=inputMatDir, collapse_mode="maxSD", naPer=0.7, meanPer=0.8, varPer=0.8, corrType="spearman", matNetMethod="rank", valueThr=0.6, rankBest=0.003, networkType="signed", netFDRMethod="BH", netFDRThr=0.05, idNumThr=(-1),nThreads=3)
inputMatDir <- system.file("extdata","exampleExpressionData.cct",package="NetSAM") matNetwork <- MatNet(inputMat=inputMatDir, collapse_mode="maxSD", naPer=0.7, meanPer=0.8, varPer=0.8, corrType="spearman", matNetMethod="rank", valueThr=0.6, rankBest=0.003, networkType="signed", netFDRMethod="BH", netFDRThr=0.05, idNumThr=(-1),nThreads=3)
The MatSAM function first uses MatNet function to identify the correlation network and then uses NetSAM function to identify the module and optimize the one-dimensional ordering of the nodes in each module.
MatSAM(inputMat, sampleAnn=NULL, outputFileName, outputFormat="msm", organism="hsapiens", map_to_symbol=FALSE, idType="auto", collapse_mode="maxSD", naPer=0.7, meanPer=0.8, varPer=0.8, corrType="spearman", matNetMethod="rank", valueThr=0.5, rankBest=0.003, networkType="signed", netFDRMethod="BH", netFDRThr=0.05, minModule=0.003, stepIte=FALSE, maxStep=4, moduleSigMethod="cutoff", modularityThr=0.2, ZRanNum=10, PerRanNum=100, ranSig=0.05, idNumThr=(-1), nThreads=3)
MatSAM(inputMat, sampleAnn=NULL, outputFileName, outputFormat="msm", organism="hsapiens", map_to_symbol=FALSE, idType="auto", collapse_mode="maxSD", naPer=0.7, meanPer=0.8, varPer=0.8, corrType="spearman", matNetMethod="rank", valueThr=0.5, rankBest=0.003, networkType="signed", netFDRMethod="BH", netFDRThr=0.05, minModule=0.003, stepIte=FALSE, maxStep=4, moduleSigMethod="cutoff", modularityThr=0.2, ZRanNum=10, PerRanNum=100, ranSig=0.05, idNumThr=(-1), nThreads=3)
inputMat |
|
sampleAnn |
|
outputFileName |
Output file name. The file name extension is "msm" which can be uploaded to the NetGestalt directly. |
outputFormat |
The format of the output file. "msm" format can be used as an input in NetGestalt; "gmt" format can be used to do other network analysis (e.g. as an input in GSEA (Gene Set Enrichment Analysis) to do module enrichment analysis); "multiple" represents the MatSAM function will output five files: ruler file containing gene order information, hmi file containing module information, net file containing correlation network information, cct file containing the filtered data matrix, and tsi file containing the sample annotation with standardized format; and "none" represents the function will not output any file. |
organism |
The organism of the input data. Currently, the package supports the following nine organisms: hsapiens, mmusculus, rnorvegicus, drerio, celegans, scerevisiae, cfamiliaris, dmelanogaster and athaliana. The default is "hsapiens". |
map_to_symbol |
If |
idType |
The id type of the ids in the input matrix. MatSAM will use BiomaRt package to transform the input ids to gene symbols based on |
collapse_mode |
The method to collapse duplicate ids. "mean", "median", "maxSD", "maxIQR", "max" and "min" represent the mean, median, max standard deviation, max interquartile range, maximum and minimum of values for ids in each sample. The default is "maxSD". |
naPer |
To remove ids with missing values in most of samples, the function calculates the percentage of missing values in all samples for each id and removes ids with over |
meanPer |
To remove ids with low values, the function calculates the mean of values for a id in all samples and remains top |
varPer |
Based on the remained ids filtered by |
corrType |
A character string indicating which correlation coefficient is to be computed for each pair of ids. The function supports "spearman" (default) or "pearson" method. |
matNetMethod |
MatNet function supports three methods to construct correlation network: "value", "rank" and "directed". 1. "value" method: the correlation network only remains id pairs with correlations over cutoff threshold |
valueThr |
Correlation cutoff threshold for "value" method. The default is 0.5. |
rankBest |
The percentage of ids that are most similar to one id for "rank" method. The default is 0.003 which means the "rank" method will select top 30 most similar ids for each id if the number of ids in the matrix is 10,000. |
networkType |
If |
netFDRMethod |
p value adjustment methods for "rank" and "directed" methods. The default is "BH". |
netFDRThr |
fdr threshold for identifying significant pairs for "rank" and "directed" methods. The default is 0.05 |
minModule |
The minimum percentage of nodes in a module. The minimum size of a module is calculated by multiplying |
stepIte |
Because NetSAM uses random walk distance-based hierarchical clustering to reveal the hierarchical organization of an input network, it requires a specified length of the random walks. If |
maxStep |
The length or max length of the random walks. |
moduleSigMethod |
To test whether a network under consideration has a non-random internal modular organization, the function provides three options: "cutoff", "zscore" and "permutation". "cutoff" means if the modularity score of the network is above a specified cutoff value, the network will be considered to have internal organization and will be further partitioned. For "zscore" and "permutation", the function will first generate a set of random modularity scores. Based on a unweighted network, the function uses the edge switching method to generate a given number of random networks with the same number of nodes and an identical degree sequence and calculates the modularity scores for these random networks. Based on a weighted network, the function shuffles the weights of all edges and calculate the modularity scores for network with random weights. Then, "zscore" method will transform the real modularity score to a z score based on the random modularity scores and then transform the z score to a p value assuming a standard normal distribution. The "permutation" method will compare the real modularity score with the random ones to calculate a p value. Finally, under a specified significance level, the function determines whether the network can be further partitioned. The default is "cutoff". |
modularityThr |
Threshold of modularity score for the "cutoff" method. The default is 0.2 |
ZRanNum |
The number of random networks that will be generated for the "zscore" calculation. The default is 10. |
PerRanNum |
The number of random networks that will be generated for the "permutation" p value calculation. The default is 100. |
ranSig |
The significance level for determining whether a network has non-random internal modular organization for the "zscore" or "permutation" methods. The default is 0.05. |
idNumThr |
If the matrix contains too many ids, it will take a long time and use a lot of memory to identify the modules. Thus, the function provides the option to set the threshold of number of ids for further analysis. After filtering by meanPer and varPer, if the number of ids is still larger than |
nThreads |
MatSAM function supports parallel computing based on multiple cores. The default is 3. |
Including a "msm" file, the function will output a list object containing module information, gene order information, correlation network and filtered matrix based on the ids in the network. The function will also output two HTML files that contain the significant associations between sample features and modules and associated GO terms for the modules.
After identifying the modules, the MatSAM function will identify the associations between sample features and modules using the featureAssociation function or the associated GO terms for the modules using the GOAssociation function. For the featureAssociation function, MatSAM only uses the default parameters. For the GOAssociation function, MatSAM sets "outputType" as "top" and "topNum" as 1. The users can use the list object returned by MatSAM as the input of the function featureAssociation and GOAssociation to perform some further analysis based on the different parameters.
Jing Wang
inputMatDir <- system.file("extdata","exampleExpressionData.cct",package="NetSAM") cat(inputMatDir) sampleAnnDir <- system.file("extdata","sampleAnnotation.tsi",package="NetSAM") cat(sampleAnnDir) outputFileName <- paste(getwd(),"/MatSAM",sep="") matModule <- MatSAM(inputMat=inputMatDir, sampleAnn=sampleAnnDir, outputFileName=outputFileName, outputFormat="msm", organism="hsapiens", map_to_symbol=FALSE, idType="auto", collapse_mode="maxSD", naPer=0.7, meanPer=0.8, varPer=0.8, corrType="spearman", matNetMethod="rank", valueThr=0.6, rankBest=0.003, networkType="signed", netFDRMethod="BH", netFDRThr=0.05, minModule=0.003, stepIte=FALSE, maxStep=4, moduleSigMethod="cutoff", modularityThr=0.2, ZRanNum=10, PerRanNum=100, ranSig=0.05, idNumThr=(-1), nThreads=3)
inputMatDir <- system.file("extdata","exampleExpressionData.cct",package="NetSAM") cat(inputMatDir) sampleAnnDir <- system.file("extdata","sampleAnnotation.tsi",package="NetSAM") cat(sampleAnnDir) outputFileName <- paste(getwd(),"/MatSAM",sep="") matModule <- MatSAM(inputMat=inputMatDir, sampleAnn=sampleAnnDir, outputFileName=outputFileName, outputFormat="msm", organism="hsapiens", map_to_symbol=FALSE, idType="auto", collapse_mode="maxSD", naPer=0.7, meanPer=0.8, varPer=0.8, corrType="spearman", matNetMethod="rank", valueThr=0.6, rankBest=0.003, networkType="signed", netFDRMethod="BH", netFDRThr=0.05, minModule=0.003, stepIte=FALSE, maxStep=4, moduleSigMethod="cutoff", modularityThr=0.2, ZRanNum=10, PerRanNum=100, ranSig=0.05, idNumThr=(-1), nThreads=3)
The mergeDuplicate function will merge the duplicate Ids in the matrix data and return the matrix with unique Ids. This function can also used to merge the duplicate mapped Ids when transforming the Ids of data matrix to other Ids.
mergeDuplicate(id, data, collapse_mode="maxSD")
mergeDuplicate(id, data, collapse_mode="maxSD")
id |
Duplicate Ids that should be a vector object in R. |
data |
the corresponding data matrix that has the same number of rows with |
collapse_mode |
The method to collapse duplicate ids. "mean", "median", "maxSD", "maxIQR", "max" and "min" represent the mean, median, max standard deviation, max interquartile range, maximum and minimum of values for ids in each sample. The default is "maxSD". |
The function will return the data matrix with unique Ids.
Jing Wang
inputMatDir <- system.file("extdata","exampleExpressionData_nonsymbol.cct",package="NetSAM") inputMat <- read.table(inputMatDir,header=TRUE,sep="\t",stringsAsFactors=FALSE,check.names=FALSE) mergedData <- mergeDuplicate(id=inputMat[,1],data=inputMat[,2:ncol(inputMat)],collapse_mode="maxSD")
inputMatDir <- system.file("extdata","exampleExpressionData_nonsymbol.cct",package="NetSAM") inputMat <- read.table(inputMatDir,header=TRUE,sep="\t",stringsAsFactors=FALSE,check.names=FALSE) mergedData <- mergeDuplicate(id=inputMat[,1],data=inputMat[,2:ncol(inputMat)],collapse_mode="maxSD")
The NetAnalyzer function can calculate the degree, clustering coefficient, betweeness and closeness centrality for each node and the shortest path distance for each pair of nodes. The NetAnalyzer function can also plot the distributions for these measurements.
NetAnalyzer(inputNetwork, outputFileName,edgeType="unweighted")
NetAnalyzer(inputNetwork, outputFileName,edgeType="unweighted")
inputNetwork |
The network under analysis. |
edgeType |
The type of the input network: "weighted" or "unweighted". |
outputFileName |
The name of the output file. |
The function will output two "txt" files and five "pdf" files. Two "txt" files contain degree, clustering coefficient, betweeness and closeness centrality for each node and the shortest path distance for each pair of nodes. Five "pdf" files are the distributions of these measurements.
Jing Wang
inputNetworkDir <- system.file("extdata","exampleNetwork.net",package="NetSAM") outputFileName <- paste(getwd(),"/NetSAM",sep="") NetAnalyzer(inputNetworkDir,outputFileName,"unweighted")
inputNetworkDir <- system.file("extdata","exampleNetwork.net",package="NetSAM") outputFileName <- paste(getwd(),"/NetSAM",sep="") NetAnalyzer(inputNetworkDir,outputFileName,"unweighted")
The NetSAM function uses random walk distance-based hierarchical clustering to identify the hierarchical modules of a weighted or unweighted network and then uses the optimal leaf ordering (OLO) method to optimize the one-dimensional ordering of the genes in each module by minimizing the sum of the pair-wise random walk distance of adjacent genes in the ordering.
NetSAM(inputNetwork, outputFileName, outputFormat="nsm", edgeType="unweighted", map_to_genesymbol=FALSE, organism="hsapiens", idType="auto",minModule=0.003, stepIte=FALSE, maxStep=4, moduleSigMethod="cutoff", modularityThr=0.2, ZRanNum=10, PerRanNum=100, ranSig=0.05, edgeThr=(-1), nodeThr=(-1), nThreads=3)
NetSAM(inputNetwork, outputFileName, outputFormat="nsm", edgeType="unweighted", map_to_genesymbol=FALSE, organism="hsapiens", idType="auto",minModule=0.003, stepIte=FALSE, maxStep=4, moduleSigMethod="cutoff", modularityThr=0.2, ZRanNum=10, PerRanNum=100, ranSig=0.05, edgeThr=(-1), nodeThr=(-1), nThreads=3)
inputNetwork |
The network under analysis. |
edgeType |
The type of the input network: "weighted" or "unweighted". |
outputFileName |
The name of the output file. |
outputFormat |
The format of the output file. "nsm" format can be used as an input in NetGestalt; "gmt" format can be used to do other network analysis (e.g. as an input in GSEA (Gene Set Enrichment Analysis) to do module enrichment analysis); "multiple" represents the NetSAM function will output three files: ruler file containing gene order information, hmi file containing module information and net file containing network information; and "none" represents the function will not output any file. |
map_to_genesymbol |
Because pathway enrichment analysis in NetGestalt is based on gene symbol, setting |
organism |
The organism of the input network. Currently, the package supports the following nine organisms: hsapiens, mmusculus, rnorvegicus, drerio, celegans, scerevisiae, cfamiliaris, dmelanogaster and athaliana. The default is "hsapiens". |
idType |
The id type of the ids in the input network. MatSAM will use BiomaRt package to transform the input ids to gene symbols based on |
minModule |
The minimum percentage of nodes in a module. The minimum size of a module is calculated by multiplying |
stepIte |
Because NetSAM uses random walk distance-based hierarchical clustering to reveal the hierarchical organization of an input network, it requires a specified length of the random walks. If |
maxStep |
The length or max length of the random walks. |
moduleSigMethod |
To test whether a network under consideration has a non-random internal modular organization, the function provides three options: "cutoff", "zscore" and "permutation". "cutoff" means if the modularity score of the network is above a specified cutoff value, the network will be considered to have internal organization and will be further partitioned. For "zscore" and "permutation", the function will first generate a set of random modularity scores. Based on a unweighted network, the function uses the edge switching method to generate a given number of random networks with the same number of nodes and an identical degree sequence and calculates the modularity scores for these random networks. Based on a weighted network, the function shuffles the weights of all edges and calculate the modularity scores for network with random weights. Then, "zscore" method will transform the real modularity score to a z score based on the random modularity scores and then transform the z score to a p value assuming a standard normal distribution. The "permutation" method will compare the real modularity score with the random ones to calculate a p value. Finally, under a specified significance level, the function determines whether the network can be further partitioned. The default is "cutoff". |
modularityThr |
Threshold of modularity score for the "cutoff" method. The default is 0.2 |
ZRanNum |
The number of random networks that will be generated for the "zscore" calculation. The default is 10. |
PerRanNum |
The number of random networks that will be generated for the "permutation" p value calculation. The default is 100. |
ranSig |
The significance level for determining whether a network has non-random internal modular organization for the "zscore" or "permutation" methods. |
edgeThr |
If the network is too big, it will take a long time to identify the modules. Thus, the function provides the option to set the threshold of number of edges and nodes as |
nodeThr |
see |
nThreads |
NetSAM function supports parallel computing based on multiple cores. The default is 3. |
If output format is "nsm", the function will output not only a "nsm" file but also a list object containing module information, gene order information and network information. If output format is "gmt", the function will output the "gmt" file and a matrix object containing the module and annotation information.
Because the seriation step requires pair-wise distance between all nodes, NetSAM is memory consuming. We recommend to use the 64 bit version of R to run the NetSAM. For networks with less than 10,000 nodes, we recommend to use a computer with 8GB memory. For networks with more than 10,000 nodes, a computer with at least 16GB memory is recommended.
Jing Wang
inputNetworkDir <- system.file("extdata","exampleNetwork.net",package="NetSAM") outputFileName <- paste(getwd(),"/NetSAM",sep="") result <- NetSAM(inputNetwork=inputNetworkDir, outputFileName=outputFileName, outputFormat="nsm", edgeType="unweighted", map_to_genesymbol=FALSE, organism="hsapiens", idType="auto",minModule=0.003, stepIte=FALSE, maxStep=4, moduleSigMethod="cutoff", modularityThr=0.2, ZRanNum=10, PerRanNum=100, ranSig=0.05, edgeThr=(-1), nodeThr=(-1), nThreads=3)
inputNetworkDir <- system.file("extdata","exampleNetwork.net",package="NetSAM") outputFileName <- paste(getwd(),"/NetSAM",sep="") result <- NetSAM(inputNetwork=inputNetworkDir, outputFileName=outputFileName, outputFormat="nsm", edgeType="unweighted", map_to_genesymbol=FALSE, organism="hsapiens", idType="auto",minModule=0.003, stepIte=FALSE, maxStep=4, moduleSigMethod="cutoff", modularityThr=0.2, ZRanNum=10, PerRanNum=100, ranSig=0.05, edgeThr=(-1), nodeThr=(-1), nThreads=3)
The list object contains at least three parts: gene order information, module information and network information. This object can be used as an input of the function featureAssociation or GOAssociation.
data(NetSAMOutput_Example)
data(NetSAMOutput_Example)
list
The testFileFormat function will test the format of the input data matrix and annotation data and return the standardized data matrix and sample annotation data.
testFileFormat(inputMat=NULL,sampleAnn=NULL,collapse_mode="maxSD")
testFileFormat(inputMat=NULL,sampleAnn=NULL,collapse_mode="maxSD")
inputMat |
|
sampleAnn |
|
collapse_mode |
The method to collapse duplicate ids. "mean", "median", "maxSD", "maxIQR", "max" and "min" represent the mean, median, max standard deviation, max interquartile range, maximum and minimum of values for ids in each sample. The default is "maxSD". |
If there is no format error, the function will return the standardized data matrix and sample annotation data. Otherwise, the function will output the detailed position of the errors.
If the users set inputMat as "", the testFileFormat function only test format of sample annotation data. If the users set sampleAnn as "", the testFileFormat function only test format of data matrix.
Jing Wang
inputMatDir <- system.file("extdata","exampleExpressionData.cct",package="NetSAM") sampleAnnDir <- system.file("extdata","sampleAnnotation.tsi",package="NetSAM") formatedData <- testFileFormat(inputMat=inputMatDir,sampleAnn=sampleAnnDir,collapse_mode="maxSD")
inputMatDir <- system.file("extdata","exampleExpressionData.cct",package="NetSAM") sampleAnnDir <- system.file("extdata","sampleAnnotation.tsi",package="NetSAM") formatedData <- testFileFormat(inputMat=inputMatDir,sampleAnn=sampleAnnDir,collapse_mode="maxSD")