[R] Understanding mod.matrix for directed networks
Dear Gabor, Please find attached an Excel file with detailed information on a four node directed network to calculate its pairwise modularity matrix using igraph: mod.matrix(). I have tried multiple combinations to figure out how the formula works or is applied but failed to find consistency, specially for the pairs of arcs in opposing directions where the pairwise modularity is different (highlighted and color-coded). I gave membership(wtc) as input to mod.matrix() but not even sure if its used in the formula provided in the following R manual page: http://igraph.org/r/doc/modularity.html Advice with a solved example in the Excel sheet would be deeply appreciated. Thanks and regards, Fayez University of Illinois at Urbana Champaign, USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] symm parameter of heatmap
Hi, What exactly is the difference between using symm=TRUE and symm=FALSE in a heatmap. More elaborately, when symm=FALSE, what does the heatmap plots because it seems like it changes the scale and makes it asymmetric, even if x is symmetric and square. Additionally, is it possible to view the matrix that the heatmap plots? Here is a sample code I have been testing: rm(list = ls()) g - graph.full(5) %du% graph.full(5) %du% graph.full(5) g - add.edges(g, c(1,6, 1,11, 6, 11)) adjMatrix=get.adjacency(g, sparse=FALSE) heatmap3(adjMatrix, Rowv = NA, Colv = NA, symm=FALSE) windows() heatmap3(adjMatrix, Rowv = NA, Colv = NA, symm=TRUE) Thanks, Fayez [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] meta data on infert data set
Thank you folks. Actually I did lookup all these resources you mentioned but couldn't find a word for word meta data. In fact the data set is a bit different from what's in the appendix of the paper. Also the meaning of these terms seems to be specific to the study than following the dictionary. Regards, Fayez On Feb 1, 2014 10:56 PM, David Winsemius dwinsem...@comcast.net wrote: On Feb 1, 2014, at 6:32 PM, Jeff Newmiller wrote: They appear to be technical terms relevant to fertility. You should probably ask someone with a background in medicine... or Google for these terms in conjunction with the word fertility. Parity is the only technical term and its easy enough to look up in a dictionary. (Or if you do a Google search and choose the first hit you see it accurately defined at least for its biologic meaning. The other two relate to the study design and that why the author put in a citation, which unsurprising brings up the orignal paper as the first hit with a Google search. So, Aziz, please use a bit more initiative. -- David Winsemius --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. On February 1, 2014 5:57:37 PM PST, Aziz, Muhammad Fayez az...@illinois.edu wrote: Hi, I wanted to know what the following columns mean in the infert dataset: parity count matched set number 1-83 stratum number 1-63 Thank you, Fayez Urbana, IL, USA [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius Alameda, CA, USA [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] meta data on infert data set
Hi, I wanted to know what the following columns mean in the infert dataset: parity count matched set number 1-83 stratum number 1-63 Thank you, Fayez Urbana, IL, USA [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to auto adjust panel width according to number of box plots in bwplot
Thank you so much Richard. Your solution worked like a charm. I worked out my weight vector w for each type of my plots and the results were smooth as butter. Sure I shall be succinct in display of code and data inside correspondence to r-help in future. Dennis gave me a few tips on how to do that. Thanks again, Fayez From: Richard M. Heiberger [r...@temple.edu] Sent: Monday, August 05, 2013 11:38 PM To: Aziz, Muhammad Fayez Cc: r-help@r-project.org Subject: Re: [R] How to auto adjust panel width according to number of box plots in bwplot library(lattice) library(latticeExtra) tmp - data.frame(a=1:20, b=LETTERS[rep(1:5,c(2,4,3,4,7))], cc=letters[rep(1:2, c(6,14))]) tmp bwplot(a ~ b | cc, data=tmp) bwplot(a ~ b | cc, data=tmp, scales=list(x=list(relation=free))) resizePanels(bwplot(a ~ b | cc, data=tmp, scales=list(x=list(relation=free))), w=c(2,3)) Please use minimal data in furture queries to this list. Rich On Mon, Aug 5, 2013 at 2:18 PM, Aziz, Muhammad Fayez az...@illinois.edumailto:az...@illinois.edu wrote: Hi, My question is how to auto adjust panel width according to number of box plots in bwplot. I mean if a panel has 10 box plots and another has only two, I need to make the later panel thinner than the first. I am familiar with panel.width and layout.widths params but couldn't work it in my code below. Data I am using follows. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to auto adjust panel width according to number of box plots in bwplot
Hi, My question is how to auto adjust panel width according to number of box plots in bwplot. I mean if a panel has 10 box plots and another has only two, I need to make the later panel thinner than the first. I am familiar with panel.width and layout.widths params but couldn't work it in my code below. Data I am using follows. Code: # Change from v3: Introducing panel function to color points according to network's age # courtesy: # http://www.statmethods.net/graphs/boxplot.html # http://chartsgraphs.wordpress.com/2008/11/18/boxplots-r-does-them-right/ # http://msenux.redwoods.edu/math/R/boxplot.php library('reshape') library(lattice) FilePath = C:\\Users\\Fayez\\Desktop\\Gustavo_EFL\\ File2Open = paste(FilePath, RCode\\RData\\PanelSizeData.txt, sep = ) DataTable = read.table(File2Open, header = TRUE, sep = \t) # print(DataTable) # Reshape data from wide to long # For explanation, I found a link: http://www.statmethods.net/management/reshape.html md - melt(DataTable, id.vars = c('Panels', 'Rate', 'NodeNo')) # Make variable-column = Nntnt'Age' headers numeric by stripping off the Nntnt part and coercing it to numeric md$variable - as.numeric(substr(md$variable, 6, nchar(as.character(md$variable md$NodeNo - as.character(md$NodeNo) # to show labels as characters md$NodeNo - factor(md$NodeNo, unique(md$NodeNo)) # to order the labels # Start PNG device driver to save output to figure.png png(filename = paste(FilePath, Results\\ROutput\\PanelSizeData.png, sep = ), width = 3200, height = 450) # should be in 16:9 ratio for good arrangement of panels print(bwplot(value ~ NodeNo | Panels, data = md, xlab = paste(A, sep = ), ylab = paste(B, sep = ), main = paste(Variable panel sizes, sep = ), pch = 20, # dots instead of circles horizontal=FALSE, scales = list(x = (relation = sliced), y = (relation = same), rot=90), # necessary to make x-axis in each panel adjustable according to number of domains layout = c(10, 1), # panel arrangement )) # Turn off device driver (to flush output to png) dev.off() Data: Panels RateNodeNo Nntnt0 Nntnt0.0044843 Nntnt0.0089686 Nntnt0.0134529 Nntnt0.0179372 Nntnt0.0313901 Nntnt0.0358744 Nntnt0.0403587 Nntnt0.044843 Nntnt0.0538117 Nntnt0.0717489 Nntnt0.0807175 Nntnt0.0896861 Nntnt0.0941704 Nntnt0.0986547 Nntnt0.1210762 Nntnt0.1255605 Nntnt0.1300448 Nntnt0.1345291 Nntnt0.1434978 Nntnt0.1524664 Nntnt0.161435 Nntnt0.1659193 Nntnt0.1748879 Nntnt0.1838565 Nntnt0.1883408 Nntnt0.1973094 Nntnt0.206278 Nntnt0.2107623 Nntnt0.2197309 Nntnt0.2242152 Nntnt0.2466368 Nntnt0.2511211 Nntnt0.2600897 Nntnt0.264574 Nntnt0.2735426 Nntnt0.2825112 Nntnt0.2869955 Nntnt0.2959641 Nntnt0.3049327 Nntnt0.3587444 Nntnt0.4215247 Nntnt0.4618834 Nntnt0.4663677 Nntnt0.4798206 Nntnt0.4977579 Nntnt0.5156951 Nntnt0.5201794 Nntnt0.529148 Nntnt0.5336323 Nntnt0.5829597 Nntnt0.5874439 Nntnt0.5964125 Nntnt0.632287 Nntnt0.7399103 Nntnt0.7533633 Nntnt0.7668161 Nntnt0.7802691 Nntnt0.8026906 Nntnt0.8340807 Nntnt1 0.0 to 0.1 0.000 n.37.1 3 4 4 4 6 6 7 8 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 0.0 to 0.1 0.0044843 n.2.1 0 1 1 2 2 3 3 4 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 0.0 to 0.1 0.0089686 n.4.5 0 0 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 0.0 to 0.1 0.0134529 n.66.1 0 0 0 3 3
[R] Variable panel sizes in box plot
Hi, My question is how to make panel sizes variable in box plots. I mean if a panel has 10 box plots and another has only two, I need to make the later panel thinner than the first. Regards, Fayez Grad Student UIUC, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R-help Digest, Vol 126, Issue 6
Hi, My question is how to make panel sizes variable in box plots. I mean if a panel has 10 box plots and another has only two, I need to make the later panel thinner than the first. Regards, Fayez Grad Student UIUC, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Variable panel sizes in box plot
Hi Jeff, Thank you for your response. Pardon my lapse. Please find attached the code, data and output. I have used bwplot. Fayez From: Jeff Newmiller [jdnew...@dcn.davis.ca.us] Sent: Sunday, August 04, 2013 5:29 PM To: Aziz, Muhammad Fayez; r-help@r-project.org Subject: Re: [R] Variable panel sizes in box plot There are a variety of ways to make box plots (e.g. base graphics, lattice, and ggplot2). As the message footer says, you should be reading the Posting Guide and providing a reproducible example (with sample data). --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Aziz, Muhammad Fayez az...@illinois.edu wrote: Hi, My question is how to make panel sizes variable in box plots. I mean if a panel has 10 box plots and another has only two, I need to make the later panel thinner than the first. Regards, Fayez Grad Student UIUC, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.Panels RateNodeNo Nntnt0 Nntnt0.0044843 Nntnt0.0089686 Nntnt0.0134529 Nntnt0.0179372 Nntnt0.0313901 Nntnt0.0358744 Nntnt0.0403587 Nntnt0.044843 Nntnt0.0538117 Nntnt0.0717489 Nntnt0.0807175 Nntnt0.0896861 Nntnt0.0941704 Nntnt0.0986547 Nntnt0.1210762 Nntnt0.1255605 Nntnt0.1300448 Nntnt0.1345291 Nntnt0.1434978 Nntnt0.1524664 Nntnt0.161435 Nntnt0.1659193 Nntnt0.1748879 Nntnt0.1838565 Nntnt0.1883408 Nntnt0.1973094 Nntnt0.206278 Nntnt0.2107623 Nntnt0.2197309 Nntnt0.2242152 Nntnt0.2466368 Nntnt0.2511211 Nntnt0.2600897 Nntnt0.264574 Nntnt0.2735426 Nntnt0.2825112 Nntnt0.2869955 Nntnt0.2959641 Nntnt0.3049327 Nntnt0.3587444 Nntnt0.4215247 Nntnt0.4618834 Nntnt0.4663677 Nntnt0.4798206 Nntnt0.4977579 Nntnt0.5156951 Nntnt0.5201794 Nntnt0.529148 Nntnt0.5336323 Nntnt0.5829597 Nntnt0.5874439 Nntnt0.5964125 Nntnt0.632287 Nntnt0.7399103 Nntnt0.7533633 Nntnt0.7668161 Nntnt0.7802691 Nntnt0.8026906 Nntnt0.8340807 Nntnt1 0.0 to 0.1 0.000 n.37.1 3 4 4 4 6 6 7 8 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 0.0 to 0.1 0.0044843 n.2.1 0 1 1 2 2 3 3 4 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 0.0 to 0.1 0.0089686 n.4.5 0 0 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 0.0 to 0.1 0.0134529 n.66.1 0 0 0 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 0.0 to 0.1 0.0179372 n.40.4 0 0 0 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3
Re: [R] Variable panel sizes in box plot
Hi Jim, Your example works perfectly. Any possibility that the sizing could be automated. I am using bwplot. I can also use a prepanel function if needed. Please find attached the code, data and output. Fayez From: Jim Lemon [j...@bitwrit.com.au] Sent: Sunday, August 04, 2013 5:43 PM To: Aziz, Muhammad Fayez Cc: r-help@r-project.org Subject: Re: [R] Variable panel sizes in box plot On 08/05/2013 08:01 AM, Aziz, Muhammad Fayez wrote: Hi, My question is how to make panel sizes variable in box plots. I mean if a panel has 10 box plots and another has only two, I need to make the later panel thinner than the first. Hi Fayex, Try this: xdat-data.frame(a=rnorm(100),b=rnorm(100),c=rnorm(100),d=rnorm(100), e=rnorm(100),f=rnorm(100),g=rnorm(100)) dev.new(width=10,height=3) layout(matrix(1:2,nrow=1),widths=c(5,2)) boxplot(xdat[1:5]) boxplot(xdat[6:7]) JimPanels RateNodeNo Nntnt0 Nntnt0.0044843 Nntnt0.0089686 Nntnt0.0134529 Nntnt0.0179372 Nntnt0.0313901 Nntnt0.0358744 Nntnt0.0403587 Nntnt0.044843 Nntnt0.0538117 Nntnt0.0717489 Nntnt0.0807175 Nntnt0.0896861 Nntnt0.0941704 Nntnt0.0986547 Nntnt0.1210762 Nntnt0.1255605 Nntnt0.1300448 Nntnt0.1345291 Nntnt0.1434978 Nntnt0.1524664 Nntnt0.161435 Nntnt0.1659193 Nntnt0.1748879 Nntnt0.1838565 Nntnt0.1883408 Nntnt0.1973094 Nntnt0.206278 Nntnt0.2107623 Nntnt0.2197309 Nntnt0.2242152 Nntnt0.2466368 Nntnt0.2511211 Nntnt0.2600897 Nntnt0.264574 Nntnt0.2735426 Nntnt0.2825112 Nntnt0.2869955 Nntnt0.2959641 Nntnt0.3049327 Nntnt0.3587444 Nntnt0.4215247 Nntnt0.4618834 Nntnt0.4663677 Nntnt0.4798206 Nntnt0.4977579 Nntnt0.5156951 Nntnt0.5201794 Nntnt0.529148 Nntnt0.5336323 Nntnt0.5829597 Nntnt0.5874439 Nntnt0.5964125 Nntnt0.632287 Nntnt0.7399103 Nntnt0.7533633 Nntnt0.7668161 Nntnt0.7802691 Nntnt0.8026906 Nntnt0.8340807 Nntnt1 0.0 to 0.1 0.000 n.37.1 3 4 4 4 6 6 7 8 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 0.0 to 0.1 0.0044843 n.2.1 0 1 1 2 2 3 3 4 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 0.0 to 0.1 0.0089686 n.4.5 0 0 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 0.0 to 0.1 0.0134529 n.66.1 0 0 0 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 0.0 to 0.1 0.0179372 n.40.4 0 0 0 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 0.0 to 0.1 0.0313901 n.3.1 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
[R] How to interpret Poisson curve
Hi All, My question is more academic than technical. The question is about interpretation of Poisson curve. I am using it to assess scale-free nature of degree distribution. Can you please briefly describe what is meant by the Poisson curve when you give it your range of k-neighbour data which apparently follows power-law (or does otherwise). The code I am using within the xyplot.panel to plot the Poisson curve follows. y is the degrees vector. kfreq - table(y); # compute frequency hash table of y, the degrees k - 1:max(y) for (i in k) { ichar - as.character(i) # convert to match the names(freq), the character-based hash key of freq, which is degree-value if (!(ichar %in% names(kfreq))) kfreq[ichar] - 0 } sortedkeys - as.character(k) kfreq - kfreq[sortedkeys] pk - kfreq / length(y) panel.xyplot(col=blue, k, pk) #overlaying the poisson distribution poissonk - ppois(k, lambda = mean(y), lower.tail = FALSE) # lower.tail: if TRUE (default), probabilities are P[X = x], otherwise, P[X x] panel.xyplot(col=red, k, poissonk) Regrads, Fayez GCA lab - UIUC [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] community finding in a graph and heatplot
Superb. It works. The results loo great. I just tweaked the function a little bit to suit my needs though. I passed merges and vcount separately as fgc$merges and vcount(g). The vcount attribute was not there in fgc object. Also, I removed the last row from the merges matrix before returning as it was adding the very root level undesired by the heatmap.2 function I was using. The final function looks like this: # To generate a complete dendogram from disconnected subgraphs in merges given by fgc complete.dend - function(merges, vcount) { if (nrow(merges) vcount-1) { miss - seq_len(vcount + nrow(merges))[-as.vector(merges)] miss - c(miss, seq_len(length(miss)-2) + vcount+nrow(merges)) miss - matrix(miss, byrow=TRUE, ncol=2) merges - rbind(merges, miss) } storage.mode(merges) - integer merges[-nrow(merges),] # skip last row } Thank you so much Gabor for this custom complete.dend fucntion. I couldn't find it in the regular igraph library (http://igraph.sourceforge.net/doc/R/00Index.html). Best, Fayez From: csardi.ga...@gmail.com [csardi.ga...@gmail.com] on behalf of Gábor Csárdi [csa...@rmki.kfki.hu] Sent: Monday, June 04, 2012 6:33 PM To: Aziz, Muhammad Fayez Cc: r-help@r-project.org; Caetano-Anolles, Gustavo Subject: Re: [R] community finding in a graph and heatplot On Sun, Jun 3, 2012 at 4:11 PM, Aziz, Muhammad Fayez az...@illinois.edu wrote: Hmm interesting. To come to think of it there could be many disconnected components in the graph and thus there should be a generic way to either mitigate the disconnectedness in the dendrogram or in the original graph. I had no luck in finding such a trick though google search. I then ran the script on minute-scale graphs and have following results: 1) disconnected graph with three modules: *Vertices 9 *Edges 1 2 1 2 3 1 3 1 1 4 5 1 5 6 1 6 4 1 7 8 1 8 9 1 9 7 1 corresponding fgc$merges matrix: [,1] [,2] [1,]10 [2,]29 [3,]76 [4,]8 11 [5,]43 [6,]5 13 2) connected graph by adding links 1-2 and 4-7 in graph 1): *Vertices 9 *Edges 1 2 1 2 3 1 3 1 1 4 5 1 5 6 1 6 4 1 7 8 1 8 9 1 9 7 1 1 4 1 4 7 1 corresponding fgc$merges matrix: [,1] [,2] [1,]21 [2,]09 [3,]87 [4,]6 11 [5,]54 [6,]3 13 [7,] 14 12 [8,] 15 10 There needs to be a generic way to get fgc$merges of the form 2) from 1). Hints please. Well, how do you merge the unconnected components? I guess you could come up with an order based on modularity, or just merge them in arbitrary order. The following is from igraph 0.6, and I haven't tried it on your data, but it might just work. It merges the individual subtrees in arbitrary order. complete.dend - function(comm) { merges - comm$merges if (nrow(merges) comm$vcount-1) { miss - seq_len(comm$vcount + nrow(merges))[-as.vector(merges)] miss - c(miss, seq_len(length(miss)-2) + comm$vcount+nrow(merges)) miss - matrix(miss, byrow=TRUE, ncol=2) merges - rbind(merges, miss) } storage.mode(merges) - integer merges } Best, Gabor [...] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] community finding in a graph and heatplot
Hmm interesting. To come to think of it there could be many disconnected components in the graph and thus there should be a generic way to either mitigate the disconnectedness in the dendrogram or in the original graph. I had no luck in finding such a trick though google search. I then ran the script on minute-scale graphs and have following results: 1) disconnected graph with three modules: *Vertices 9 *Edges 1 2 1 2 3 1 3 1 1 4 5 1 5 6 1 6 4 1 7 8 1 8 9 1 9 7 1 corresponding fgc$merges matrix: [,1] [,2] [1,]10 [2,]29 [3,]76 [4,]8 11 [5,]43 [6,]5 13 2) connected graph by adding links 1-2 and 4-7 in graph 1): *Vertices 9 *Edges 1 2 1 2 3 1 3 1 1 4 5 1 5 6 1 6 4 1 7 8 1 8 9 1 9 7 1 1 4 1 4 7 1 corresponding fgc$merges matrix: [,1] [,2] [1,]21 [2,]09 [3,]87 [4,]6 11 [5,]54 [6,]3 13 [7,] 14 12 [8,] 15 10 There needs to be a generic way to get fgc$merges of the form 2) from 1). Hints please. Thank you so much Gabor for your help so far and marvelous job in identifying the problem. Best, Fayez From: csardi.ga...@gmail.com [csardi.ga...@gmail.com] on behalf of Gábor Csárdi [csa...@rmki.kfki.hu] Sent: Sunday, June 03, 2012 8:56 AM To: Aziz, Muhammad Fayez Cc: r-help@r-project.org; Caetano-Anolles, Gustavo Subject: Re: [R] community finding in a graph and heatplot The problem is that your graph is unconnected, it has two components and the as.dendrogram() function in igraph cannot handle that. fastgreedy.community() returns a matrix of merges that is not a complete dendrogram, the final top level merge of the components is missing. A workaround is to modify the result of fastgreedy.community and add the missing row to the merges matrix, before calling as.dendrogram(). G. On Thu, May 31, 2012 at 7:42 PM, Aziz, Muhammad Fayez az...@illinois.edu wrote: Thank you so much Gabor for taking this on. Please find attached a sample scenario with the problem of malfunctioning dendogram by fgc. I hope this helps you narrow down to the solution. Best, Fayez From: csardi.ga...@gmail.com [csardi.ga...@gmail.com] on behalf of Gábor Csárdi [csa...@rmki.kfki.hu] Sent: Thursday, May 31, 2012 4:23 PM To: Aziz, Muhammad Fayez Cc: r-help@r-project.org Subject: Re: [R] community finding in a graph and heatplot On Thu, May 31, 2012 at 12:08 PM, Aziz, Muhammad Fayez az...@illinois.edu wrote: Thank you so much Gabor for your reply. I had spotted your post earlier and it worked like a charm. Interestingly I have just ran into a trouble with the stament dend - igraph:::as.dendrogram.igraph.walktrap(fc). Apparently the members are empty as when I print(dend) it says 'dendrogram' with 2 branches and members total, at height 93 while the error with using dend with dendrapply remians to be Error in `[[.dendrogram`(X, 2L) : attempt to set an attribute on NULL Any ideas? I would need to see fgc for this. Can you send it to me in private? Or send some self-contained example that generates the same error? Gabor My code looks like this File2Open = paste(FilePath, NetworkFiles\\net\\, NetPrefix, , TPPostfix, .net, sep = ) g - read.graph(File2Open, format=pajek) g - delete.isolates(g) g - simplify(g) fgc - fastgreedy.community(g, modularity=TRUE, weights = E(g)$weight) ModularityIndexfgc - max(fgc$modularity) # fgc modularity ModularityIndexng - modularity(g, membership, weights = E(g)$weight) # newman-girvan modularity dend - igraph:::as.dendrogram.igraph.walktrap(fgc) png(filename = paste(FilePath, Analysis\\Graphs\\EColiStressModuleHeatMap, NetPrefixAbbr, TPPostfix, .png, sep = ), width = 800, height = 800) # heat map is square adjMatrix = get.adjacency(g, attr=weight) DendNodeCounter - 0 # counter for ColorGroupsOrdered ColorGroupsOrdered - rep(red, vcount(g)) dendrapply(dend, colLab) # modifies ColorGroupsOrdered From: csardi.ga...@gmail.com [csardi.ga...@gmail.com] on behalf of Gábor Csárdi [csa...@rmki.kfki.hu] Sent: Thursday, May 31, 2012 10:45 AM To: Aziz, Muhammad Fayez Cc: r-help@r-project.org Subject: Re: [R] community finding in a graph and heatplot On Tue, May 29, 2012 at 1:16 AM, Aziz, Muhammad Fayez az...@illinois.edu wrote: Hi everyone, I am using the fastgreedy.community function to get the $merges matrix and the $modularity vector. This serves my purpose of testing modularity of my graph. But I am greedy to plot the heat map and dendrrogram based on the $merges dendogram matrix. I know that heatplot does the graphics part but I am not sure if the dendogram generated by the heatplot will match
Re: [R] community finding in a graph and heatplot
Thank you so much Gabor for your reply. I had spotted your post earlier and it worked like a charm. Interestingly I have just ran into a trouble with the stament dend - igraph:::as.dendrogram.igraph.walktrap(fc). Apparently the members are empty as when I print(dend) it says 'dendrogram' with 2 branches and members total, at height 93 while the error with using dend with dendrapply remians to be Error in `[[.dendrogram`(X, 2L) : attempt to set an attribute on NULL Any ideas? My code looks like this File2Open = paste(FilePath, NetworkFiles\\net\\, NetPrefix, , TPPostfix, .net, sep = ) g - read.graph(File2Open, format=pajek) g - delete.isolates(g) g - simplify(g) fgc - fastgreedy.community(g, modularity=TRUE, weights = E(g)$weight) ModularityIndexfgc - max(fgc$modularity) # fgc modularity ModularityIndexng - modularity(g, membership, weights = E(g)$weight) # newman-girvan modularity dend - igraph:::as.dendrogram.igraph.walktrap(fgc) png(filename = paste(FilePath, Analysis\\Graphs\\EColiStressModuleHeatMap, NetPrefixAbbr, TPPostfix, .png, sep = ), width = 800, height = 800) # heat map is square adjMatrix = get.adjacency(g, attr=weight) DendNodeCounter - 0 # counter for ColorGroupsOrdered ColorGroupsOrdered - rep(red, vcount(g)) dendrapply(dend, colLab) # modifies ColorGroupsOrdered From: csardi.ga...@gmail.com [csardi.ga...@gmail.com] on behalf of Gábor Csárdi [csa...@rmki.kfki.hu] Sent: Thursday, May 31, 2012 10:45 AM To: Aziz, Muhammad Fayez Cc: r-help@r-project.org Subject: Re: [R] community finding in a graph and heatplot On Tue, May 29, 2012 at 1:16 AM, Aziz, Muhammad Fayez az...@illinois.edu wrote: Hi everyone, I am using the fastgreedy.community function to get the $merges matrix and the $modularity vector. This serves my purpose of testing modularity of my graph. But I am greedy to plot the heat map and dendrrogram based on the $merges dendogram matrix. I know that heatplot does the graphics part but I am not sure if the dendogram generated by the heatplot will match the one given by fastgreedy.community in all cases and that the heat map will represent the same clustering. No, they are different. To plot fast-greedy results as a dendrogram, see this and the follow-ups: http://lists.gnu.org/archive/html/igraph-help/2010-11/msg00059.html Gabor Tell me if my apprehension is incorrect. Otherwise please let me know of any alternatives. Here is the code I am testing so far: # http://igraph.sourceforge.net/doc/R/modularity.html # http://igraph.sourceforge.net/doc/R/fastgreedy.community.html # http://igraph.sourceforge.net/doc/R/graph.constructors.html library(igraph) library(made4) g - graph(c(1,2, 2,3, 3,1, 4,5)-1, , FALSE) print(g) ModuleInfo - fastgreedy.community(g) print(ModuleInfo) heatplot(c(1,2, 2,3, 3,1, 4,5)) Thanks Fayez Grad student UIUC IL, USA [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Gabor Csardi csa...@rmki.kfki.hu MTA KFKI RMKI __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] community finding in a graph and heatplot
Thank you so much Gabor for taking this on. Please find attached a sample scenario with the problem of malfunctioning dendogram by fgc. I hope this helps you narrow down to the solution. Best, Fayez From: csardi.ga...@gmail.com [csardi.ga...@gmail.com] on behalf of Gábor Csárdi [csa...@rmki.kfki.hu] Sent: Thursday, May 31, 2012 4:23 PM To: Aziz, Muhammad Fayez Cc: r-help@r-project.org Subject: Re: [R] community finding in a graph and heatplot On Thu, May 31, 2012 at 12:08 PM, Aziz, Muhammad Fayez az...@illinois.edu wrote: Thank you so much Gabor for your reply. I had spotted your post earlier and it worked like a charm. Interestingly I have just ran into a trouble with the stament dend - igraph:::as.dendrogram.igraph.walktrap(fc). Apparently the members are empty as when I print(dend) it says 'dendrogram' with 2 branches and members total, at height 93 while the error with using dend with dendrapply remians to be Error in `[[.dendrogram`(X, 2L) : attempt to set an attribute on NULL Any ideas? I would need to see fgc for this. Can you send it to me in private? Or send some self-contained example that generates the same error? Gabor My code looks like this File2Open = paste(FilePath, NetworkFiles\\net\\, NetPrefix, , TPPostfix, .net, sep = ) g - read.graph(File2Open, format=pajek) g - delete.isolates(g) g - simplify(g) fgc - fastgreedy.community(g, modularity=TRUE, weights = E(g)$weight) ModularityIndexfgc - max(fgc$modularity) # fgc modularity ModularityIndexng - modularity(g, membership, weights = E(g)$weight) # newman-girvan modularity dend - igraph:::as.dendrogram.igraph.walktrap(fgc) png(filename = paste(FilePath, Analysis\\Graphs\\EColiStressModuleHeatMap, NetPrefixAbbr, TPPostfix, .png, sep = ), width = 800, height = 800) # heat map is square adjMatrix = get.adjacency(g, attr=weight) DendNodeCounter - 0 # counter for ColorGroupsOrdered ColorGroupsOrdered - rep(red, vcount(g)) dendrapply(dend, colLab) # modifies ColorGroupsOrdered From: csardi.ga...@gmail.com [csardi.ga...@gmail.com] on behalf of Gábor Csárdi [csa...@rmki.kfki.hu] Sent: Thursday, May 31, 2012 10:45 AM To: Aziz, Muhammad Fayez Cc: r-help@r-project.org Subject: Re: [R] community finding in a graph and heatplot On Tue, May 29, 2012 at 1:16 AM, Aziz, Muhammad Fayez az...@illinois.edu wrote: Hi everyone, I am using the fastgreedy.community function to get the $merges matrix and the $modularity vector. This serves my purpose of testing modularity of my graph. But I am greedy to plot the heat map and dendrrogram based on the $merges dendogram matrix. I know that heatplot does the graphics part but I am not sure if the dendogram generated by the heatplot will match the one given by fastgreedy.community in all cases and that the heat map will represent the same clustering. No, they are different. To plot fast-greedy results as a dendrogram, see this and the follow-ups: http://lists.gnu.org/archive/html/igraph-help/2010-11/msg00059.html Gabor Tell me if my apprehension is incorrect. Otherwise please let me know of any alternatives. Here is the code I am testing so far: # http://igraph.sourceforge.net/doc/R/modularity.html # http://igraph.sourceforge.net/doc/R/fastgreedy.community.html # http://igraph.sourceforge.net/doc/R/graph.constructors.html library(igraph) library(made4) g - graph(c(1,2, 2,3, 3,1, 4,5)-1, , FALSE) print(g) ModuleInfo - fastgreedy.community(g) print(ModuleInfo) heatplot(c(1,2, 2,3, 3,1, 4,5)) Thanks Fayez Grad student UIUC IL, USA [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Gabor Csardi csa...@rmki.kfki.hu MTA KFKI RMKI -- Gabor Csardi csa...@rmki.kfki.hu MTA KFKI RMKI attachment: WhyNot.pngattachment: Splendid.png__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] community finding in a graph and heatplot
Hi everyone, I am using the fastgreedy.community function to get the $merges matrix and the $modularity vector. This serves my purpose of testing modularity of my graph. But I am greedy to plot the heat map and dendrrogram based on the $merges dendogram matrix. I know that heatplot does the graphics part but I am not sure if the dendogram generated by the heatplot will match the one given by fastgreedy.community in all cases and that the heat map will represent the same clustering. Tell me if my apprehension is incorrect. Otherwise please let me know of any alternatives. Here is the code I am testing so far: # http://igraph.sourceforge.net/doc/R/modularity.html # http://igraph.sourceforge.net/doc/R/fastgreedy.community.html # http://igraph.sourceforge.net/doc/R/graph.constructors.html library(igraph) library(made4) g - graph(c(1,2, 2,3, 3,1, 4,5)-1, , FALSE) print(g) ModuleInfo - fastgreedy.community(g) print(ModuleInfo) heatplot(c(1,2, 2,3, 3,1, 4,5)) Thanks Fayez Grad student UIUC IL, USA [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Panel.abline would not show beyond a certain slope value
Yup. Latest version 2.15.0 for windows solved the problem alright! Thank you Uwe. Regards, Fayez From: Uwe Ligges [lig...@statistik.tu-dortmund.de] Sent: Monday, April 09, 2012 9:56 AM To: Aziz, Muhammad Fayez Cc: r-help@r-project.org Subject: Re: [R] Panel.abline would not show beyond a certain slope value On 09.04.2012 06:31, Aziz, Muhammad Fayez wrote: Hi, Please find the code and data following. Problem appears in lines 37 - 42 of the code. I am using R.2.13.0 on WinXP. Works for me with a recent version of R (i.e. 2.15.0) / grid and lattice (i.e. 0.20-6). Please always try with recent versions of R and packages before asking. Best, Uwe Ligges Regards, Fayez PowerLawGraphsAblineQn.Râ library('reshape') library(lattice) library(igraph) # to use power.law.fit function library(latticeExtra) # to use panel.lmlineq in loglog xyplot File2Open = C:\\Documents and Settings\\All Users\\Documents\\Desktop\\Fayez\\RPractice\\PowerLawGraphsAblineQnData.txt DataTable = read.table(File2Open, header = TRUE, sep = \t) md- melt(DataTable, id.vars = c('Range', 'TheValue', 'TheNo')) # removed 'DegType' column 030312 md$variable- as.numeric(substr(md$variable, 9, nchar(as.character(md$variable mypanel4loglog- function(x, # x is the variable column in melted data, equals the Domain Nos y, # y is the value column in melted data, the degrees ... # Rest of the arguments ) { kfreq- table(y); # compute frquency hash table of y, the values k- 1:max(y) for (i in k) { ichar- as.character(i) # convert to match the names(freq), the character-based hash key of freq, which is the value if (!(ichar %in% names(kfreq))) kfreq[ichar]- 0 } sortedkeys- as.character(k) kfreq- kfreq[sortedkeys] pk- kfreq / length(y) logk- log(k) logpk- log(pk) logpk[logpk == -Inf] = # remove the -Inf or log(p(k)) = 0 values for lm function, NULL is 0-length so use instead that has length of one null character logpk- as.numeric(logpk) # converts all values to character, lm needs numeric print(rbind(logk, logpk))#write.table(rbind(k, kfreq, pk, logk, logpk), paste(FilePath, \\data, sep=), sep = \t, append = TRUE) panel.xyplot(col=blue, logk, logpk, type = c('p', 'r')) lm.r = lm(logpk ~ logk) panel.abline(coef=c(-4.847634, -1.037480)) # --- This gets drawn panel.abline(coef=c(-4.847634, -1.037481)) # --- This doesn't get drawn print(coef(lm.r)) # -4.847634 -1.349699 ; -3.377894 -1.498693 } # end mypanel4loglog myprepanel4loglog- function(x, # x is the variable column in melted data, equals the Network's ages y, # y is the value column in melted data, the degrees ... # Rest of the arguments ) { FreqTable- as.data.frame(table(y)) FreqsVector- sort(FreqTable$Freq) Min- FreqsVector[1] # first element - the lowest value frequency #print(c(Max2, length(y))) list(ylim = c(log(Min / length(y)), 0), xlim = c(0, log(max(y # log(p(k)) is always -ve as p(k) is decimal, so max(log(p(k)) is 0 } # end myprepanel4loglog print(xyplot(value ~ variable | Range, data = md, xlab = log(k); Panel = Range, ylab = log(p(k)), main = log(k) vs. log(p(k)), groups = Range, pch = 20, # dots instead of circles panel = mypanel4loglog, prepanel = myprepanel4loglog, # to set the scale of k and pk scales = list(x = (relation = free), y = (relation = free)), # necessary to make x-axis in each panel adjustable according to k )) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Print std. Error separately from mle-class object
Hi, I am using power.law.fit to get an mle-class object in tmp and print summary(tmp), coef(tmp) and logLik(tmp). I wanted to print the std. error for alpha separately as I want to show these values concisely in a graph legend. coef(summary(tmp)) displays the alpha and std. error jointly, while I need to print them separately on two lines. Regards, Fayez __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Print std. Error separately from mle-class object
Thank you Jeff for your input. I did realize just after posting the question that the summary fn returns an object whose slots can be read and that the slot containing the coefficient information is a matrix. Here is how I got the desired results through the following code in mypanel function of xyplot: tmp - power.law.fit(y, xmin=1) coefMatrix - slot(summary(tmp), coef) print(coefMatrix[alpha, Estimate]) # alpha: print(coefMatrix[alpha, Std. Error]) # Std. Error print(slot(summary(tmp), m2logL)) # -2 log L: Best, Fayez From: Jeff Newmiller [jdnew...@dcn.davis.ca.us] Sent: Wednesday, April 04, 2012 5:54 PM To: Aziz, Muhammad Fayez; r-help@r-project.org Subject: Re: [R] Print std. Error separately from mle-class object Are you aware that the summary function normally returns a data value that you can extract values from and format to your hearts desire? try str(coef(summary(tmp))) and read ?mle-class (and try to provide a reproducible example next time) --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Aziz, Muhammad Fayez az...@illinois.edu wrote: Hi, I am using power.law.fit to get an mle-class object in tmp and print summary(tmp), coef(tmp) and logLik(tmp). I wanted to print the std. error for alpha separately as I want to show these values concisely in a graph legend. coef(summary(tmp)) displays the alpha and std. error jointly, while I need to print them separately on two lines. Regards, Fayez __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to access value of the conditioning variable in my panel
Hi, I have 10 panels in the mypanel function of my xyplot based on the conditioning variable and I want to print those ten values, panel headings, groups, .. whatever you want to call them. Easiest way please! Fayez [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.