Re: [R] Three way correspondence analyses?
0.06, 0.04, 0.03, 0, 0.01, 0.05, 0.05, 0.01, 0.07, 0.05, 0.09)), .Names = c("fatty.acids", "aldehydes", "alcohol", "amines", "phenolic.acid", "sugars", "amino.acids", "osmolytes", "energy.related.acid", "nucleobase" ), class = "data.frame", row.names = c("I100A", "I100B", "I100C", "I100D", "I100E", "I100F", "I100G", "I123A", "I143A", "I143B", "I14A", "I14B", "I14C", "I14D", "I17A", "I17B", "I17C", "I17D", "I17E", "I185A", "I185B", "I185C", "I185D", "I185E", "I185F", "I185G", "I20A", "I20B", "I20C", "I215A", "I215B", "I215C", "I215D", "I50A", "I50B", "I50C", "I50D", "I50E", "I78A", "I78B", "I88A", "I88B", "I88C", "I88D")) Now I normalised them all by % and tried cca in vegan package. normCytok_and_ProInf <- (Cytok_and_ProInf/rowSums(Cytok_and_ProInf))*100 normMetab_NEC <- (Metab_NEC/rowSums(Metab_NEC))*100 normMicrobiome_NEC <- (Microbiome_NEC/rowSums(Microbiome_NEC))*100 #Now CCA Metab.Cytok.Microb.cca <- cca(normMicrobiome_NEC,normMetab_NEC,normCytok_and_ProInf) plot(Metab.Cytok.Microb.cca ) Metab.Cytok.Microb.cca <- cca(normMicrobiome_NEC,normCytok_and_ProInf) plot(Metab.Cytok.Microb.cca ) Metab.Cytok.Microb.cca <- cca(normMicrobiome_NEC,normMetab_NEC) plot(Metab.Cytok.Microb.cca ) Any help will be really great. Thank you very much. Mitra On 4 August 2016 at 14:25, Michael Friendly wrote: > You haven't supplied any data, and we can only guess which cca() function > you are using (ade4::cca, ..., vegan::cca(), yacca::cca), and the term > 'cca' generally refers to canonical correspondence analysis, > which is not quite the same thing as 'three-way correspondence analysis'. > > For three-way tables, there are several variations of standard > correspondence analysis that generalize CA for two-way tables > in reasonable, but different ways. > You may find more joy using the mjca() in the ca package > which provides these alternatives. > > best, > -Michael > > > On 8/2/2016 3:58 PM, Suparna Mitra wrote: > >> Hello R experts, >>have some data for microbiome, metabolome and cytokine from the same >> sample. Now I want to do a three-way correspondence analyses. From three >> normalised data I was trying, >> #Now CCA >> >> with two data it works good like: >> Metab.Cytok.Microb.cca <- cca(normMicrobiome_NEC,normCytok_and_ProInf) >> plot(Metab.Cytok.Microb.cca ) >> Metab.Cytok.Microb.cca <- cca(normMicrobiome_NEC,normMetab_NEC) >> plot(Metab.Cytok.Microb.cca ) >> >> But when I tried with three >> Metab.Cytok.Microb.cca <- >> cca(normMicrobiome_NEC,normMetab_NEC,normCytok_and_ProInf) >> plot(Metab.Cytok.Microb.cca ) >> But this is not displaying all three variables. >> Sorry, I am very new in this. Can anybody please help me? >> Thanks a lot, >> Mitra >> >> [[alternative HTML version deleted]] >> >> > [[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.
[R] Three way correspondence analyses?
Hello R experts, have some data for microbiome, metabolome and cytokine from the same sample. Now I want to do a three-way correspondence analyses. From three normalised data I was trying, #Now CCA with two data it works good like: Metab.Cytok.Microb.cca <- cca(normMicrobiome_NEC,normCytok_and_ProInf) plot(Metab.Cytok.Microb.cca ) Metab.Cytok.Microb.cca <- cca(normMicrobiome_NEC,normMetab_NEC) plot(Metab.Cytok.Microb.cca ) But when I tried with three Metab.Cytok.Microb.cca <- cca(normMicrobiome_NEC,normMetab_NEC,normCytok_and_ProInf) plot(Metab.Cytok.Microb.cca ) But this is not displaying all three variables. Sorry, I am very new in this. Can anybody please help me? Thanks a lot, Mitra [[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.
[R] Writing multiple adonis output from multiple list file in R
Hello R experts, I am trying to do adonis (vegan package) on multiple files using loop. But I am having hard time in this. Here is what I tried. setwd("PATH") files <- list.files(pattern = "[.]txt$") ldf <- lapply(files, read.table, row.names=1) str(ldf) res <- lapply(ldf, summary) for (i in length(res)) {Addon[[i]]<-adonis(vegdist(t(ldf[[i]]))~Factor) } print(i) But obviously this is not working. Until the list it works fine. Also if I test with print(adonis(vegdist(t(ldf[[1]]))~Factor)), this also provised correct result. But specifying the Addon[[i]], is something wrong. Please help, Thanks a lot, Mitra [[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.
[R] Propensity score matching with MatchIt
Hello R experts, I am trying to do Propensity score matching for a medical data with two types of surgery. But somehow I am getting Summary of balance for all data and the matched data exactly similar resulting the Percent Balance Improvement as zero. > surgery.data<-read.csv(file.choose(), head = TRUE) > surgery.data Sample Surgerytype Age ASAgrade BMI FIGOstage PreviousAbdoSurgery 1 2 1 411 22.3 3 0 2 4 1 492 19.5 3 0 3 5 1 582 28.8 3 0 4 8 1 341 29.1 3 0 5 9 1 491 25.1 3 0 6 13 1 302 29.0 3 0 7 14 1 311 23.6 3 0 8 15 1 291 33.7 3 2 9 20 1 251 24.6 3 0 10 28 1 281 21.0 3 0 11 29 1 292 21.4 3 0 12 30 1 611 25.2 3 3 13 32 1 481 22.7 3 0 14 33 1 241 26.1 3 3 15 34 1 391 23.7 3 0 16 36 1 392 34.6 3 1 17 37 1 682 27.0 3 0 18 49 1 712 30.8 3 3 19 50 1 732 25.8 3 0 20 54 1 302 23.1 3 0 21 65 1 452 34.6 3 0 22 77 1 411 29.8 3 3 23 82 1 412 33.8 3 0 24 86 1 341 34.7 3 0 25 87 1 282 21.4 3 0 26 88 1 351 25.5 3 2 27 89 1 461 31.9 3 1 28 91 1 482 20.7 3 0 29 92 1 282 22.4 3 2 30 96 1 451 22.7 3 1 31 97 1 392 19.7 3 1 32 98 1 341 27.6 3 2 33101 1 411 22.5 3 0 34107 1 312 31.0 3 0 35113 1 512 33.2 3 0 36114 1 432 22.5 3 2 37 6 0 501 22.9 3 0 38 7 0 432 25.6 3 0 39 11 0 431 23.8 3 2 40 12 0 311 22.0 3 0 41 16 0 311 27.2 3 2 42 17 0 341 19.6 3 0 43 18 0 563 25.2 3 0 44 21 0 391 26.6 3 0 45 25 0 642 24.5 3 0 46 45 0 611 21.9 3 0 47 47 0 641 28.5 3 0 48 53 0 542 26.8 5 0 49 55 0 401 23.1 3 0 50 57 0 461 26.2 3 3 51 59 0 341 21.5 3 0 52 62 0 252 23.8 3 0 53 63 0 562 24.6 3 0 54 64 0 451 24.2 3 0 55 66 0 421 30.4 3 0 56 67 0 492 35.8 2 0 57 69 0 631 24.7 3 0 58 70 0 291 29.7 5 0 59 71 0 391 19.9 3 3 60 73 0 621 28.0 3 0 61 74 0 241 26.7 3 0 62 75 0 702 31.2 3 4 63 76 0 422 23.0 3 0 64 79 0 561 34.9 3 0 65 81 0 401 25.0 3 0 66 83 0 392 29.6 3
Re: [R] Problem loading mvabund package
Thank you Michael :) S On 28 August 2015 at 12:09, Michael Dewey wrote: > Dear Suparna, > > See below > > On 28/08/2015 10:22, Suparna Mitra wrote: > >> Hello, >>Can anybody please help me with mvabund package installation? >> I downloaded and installed it. It seems installed, but I can't load the >> package. >> Here is what I tried: >> >> >> install.packages("/Users/smitra/Documents/Soft/mvabund_3.10.4.tgz", repos >>> >> = NULL, type="source") >> * installing *binary* package ‘mvabund’ ... >> * DONE (mvabund) >> >> library(mvabund) >>> >> Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) >> : >>there is no package called ‘tweedie’ >> > > There are two possibilities here > 1 - you have not installed tweedie > 2 - you have and R cannot find it > > Error: package or namespace load failed for ‘mvabund’ >> >> >> Any help will be great. >> Thanks. >> Suparna >> >> [[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. >> >> > -- > Michael > http://www.dewey.myzen.co.uk/home.html > [[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.
[R] Problem loading mvabund package
Hello, Can anybody please help me with mvabund package installation? I downloaded and installed it. It seems installed, but I can't load the package. Here is what I tried: > install.packages("/Users/smitra/Documents/Soft/mvabund_3.10.4.tgz", repos = NULL, type="source") * installing *binary* package ‘mvabund’ ... * DONE (mvabund) > library(mvabund) Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : there is no package called ‘tweedie’ Error: package or namespace load failed for ‘mvabund’ Any help will be great. Thanks. Suparna [[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.
[R] Fwd: Converting Lat Lon data in coordinates in R
Hi âHello , âCan anybody please let me know how can I convert Lat/Lon data in coordinates in R. I was trying to use the rgdal package â and proj4 packageâ . But being bit confused how to use S or N information. âand degree min second information. Any example help will be great.â My data looks like: Latitude Longitude 22º54'57"S 47º08'50"W 22º49â38ââS 47º03â49ââW 22º54'13"S 47º01'08"W 22º50'39"S 47º05'47"W 22º49'10"S 47º03'34"W 3º5'47"S 59º59'24"W 2º55'47"S 59°58'32"W 40º49â20ââN 77º49â58ââW âThanks, Mitra [[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] [BioC] problem in getVarianceStabilizedData
Thanks a lot Michael, Thats a great help. Best wishes, Suparna Dr. Suparna Mitra Department of Molecular and Clinical Pharmacology Institute of Translational Medicine University of Liverpool Block A: Waterhouse Buildings 1-5 Brownlow Street Liverpool L69 3GL Tel. +44 (0)151 795 5414 M: +44 (0) 7523228621 Internal ext: 55401 On 27 January 2014 21:18, Michael Love wrote: > hi Suparna, > > CountDataSet is the class used in DESeq, while DESeqDataSet is the class > used in DESeq2. > > You can convert a CountDataSet to a DESeqDataSet using the steps outlined > in the vignette, "1.2.3 Count matrix input". > > Mike > > > > > On Sun, Jan 26, 2014 at 11:28 PM, Suparna Mitra < > suparna.mitra...@gmail.com> wrote: > >> Hi All, >> I am having a problem while running getVarianceStabilizedData in DDSeq2 >> package. >> >> data.vsd<-getVarianceStabilizedData(data) >> Error in (function (classes, fdef, mtable) : >> unable to find an inherited method for function dispersionFunction for >> signature "CountDataSet" >> >> Though the function looks okay >> > dispersionFunction >> standardGeneric for "dispersionFunction" defined from package "DESeq2" >> >> function (object) >> standardGeneric("dispersionFunction") >> >> Methods may be defined for arguments: object >> Use showMethods("dispersionFunction") for currently available ones. >> >> Can anybody please help? >> Thanks, >> Mitra. >> >> [[alternative HTML version deleted]] >> >> >> ___ >> Bioconductor mailing list >> bioconduc...@r-project.org >> https://stat.ethz.ch/mailman/listinfo/bioconductor >> Search the archives: >> http://news.gmane.org/gmane.science.biology.informatics.conductor >> > > [[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] problem in getVarianceStabilizedData
Hi All, I am having a problem while running getVarianceStabilizedData in DDSeq2 package. data.vsd<-getVarianceStabilizedData(data) Error in (function (classes, fdef, mtable) : unable to find an inherited method for function dispersionFunction for signature "CountDataSet" Though the function looks okay > dispersionFunction standardGeneric for "dispersionFunction" defined from package "DESeq2" function (object) standardGeneric("dispersionFunction") Methods may be defined for arguments: object Use showMethods("dispersionFunction") for currently available ones. Can anybody please help? Thanks, Mitra. [[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] Bootstrap or subsampling using loop?
Hello R experts, I am trying to do a job where I need to take random subsample from a data and then frequency count of that. Then the median or the frequency from say, 1000 replicates. Should I try this with subsample in loop or bootstrap? My data format is > str(Data) 'data.frame': 155752 obs. of 2 variables: $ ReadName: Factor w/ 155752 levels "HWI-ST884185C1PEWACXX:3:1101:10047:62439#0/2",..: 49 325 800 624 786 77 203 825 249 369 ... $ Taxa: Factor w/ 25 levels "Acidimicrobium",..: 1 1 1 1 1 1 1 1 1 1 .. and then if I take 10 sample like > Data[sample(nrow(Data), 10), ] ReadName Taxa 122657 HWI-ST884185C1PEWACXX:4:2105:16386:68246#0/2 Frankia 91721 HWI-ST884185C1PEWACXX:3:2314:16967:14996#0/1 Rhodococcus 62980 HWI-ST884185C1PEWACXX:4:2101:13052:29946#0/1 Mycobacterium And count the frequency as: counts <- ddply(Sample, .(Sample$Taxa), nrow), which results like > counts Sample$Taxa V1 1 Actinomyces 1 2 Frankia 3 3 Gordonia 1 4 Modestobacter 1 5 Mycobacterium 2 6 Rhodococcus 1 7 Tsukamurella 1 Now I need to do this 1000 times and get a median of counts (V1 col). Can you please suggest the quickest way? I want to do this with really big data, and my subsample size will be 1 mil, replicate 1000, out of 10 mil size (row) data. Thanks a lot for help. Mitra [[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] package seriation- how to manage font size and label margin
Hello R experts, I am trying to use hmap from package seriation or bertinplot. I have two questions: How can I specify smaller font? I tried with pushViewport(viewport(layout=grid.layout(nrow = 1, ncol = 2), + gp = gpar(fontsize = 8))) but didn't work for the font with bertinplot. Also for hmap I need to arrange the margin so that all the labels are visible. I tried with par(mai=c(3,2,2,2)), but also with no luck. Any help will be really great. Thanks a lot, Mitra. [[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] Changing legend to fill colour in ggplot
Thanks a lot Biran, This is exactly what I was looking for. Thanks a ton. B est wishes, Mitra On 29 June 2013 02:51, Brian Diggs wrote: > On 6/27/2013 12:34 AM, Suparna Mitra wrote: > > Hello R experts, > >I am having a problem to edit legend in ggplot using four variables. > > > > My data structure is : > > str(df) > > 'data.frame': 10 obs. of 6 variables: > > $ id: Factor w/ 2 levels "639A","640": 1 1 1 1 > 1 2 > > 2 2 2 2 > > $ species : Factor w/ 5 levels > "acinetobacter_sp",..: 2 > > 5 1 4 3 2 5 1 4 3 > > $ genome_coverage_bp: int 8196 3405 8625 22568 2128 6100 1841 > > 3914 8487 1064 > > $ genome_length : int 3571237 2541445 3912725 3479613 > 5460977 > > 3571237 2541445 3912725 3479613 5460977 > > $ genome_coverage_percentage: Factor w/ 10 levels "0.02%","0.04%",..: > 8 5 > > 7 10 2 6 3 4 9 1 > > $ avg_depth_coverage: num 121.96 2.81 19.84 399.63 1.64 ... > > > > > > Now what I did is > > > p=ggplot(df,aes(genome_coverage_percentage,avg_depth_coverage))+geom_point(aes(colour > > = species,shape = factor(id))) > > p+scale_shape_discrete(name ="",labels=c("Patient 1", "Patient 2")) > > That creats the plot below. > > But I want to change the circles of legend in fill colour. So that it > > doesn't look like it is only from Patient 1, as that also has circle. > > Can anybody help me please? > > You can change the default aesthetics displayed in the legend using the > override.aes argument to guide_legend. > > scale_colour_discrete(guide=guide_legend(override.aes=aes(shape=15))) > > Also, when giving data, especially a data set this small, give the > output of dput(df) as that gives the complete data in a format that can > be used to recreate it exactly in someoneelse's session. If I had that, > I would test this to make sure it looks right. > > > Thanks a lot in advance :) > > Mitra > > > > > > > > > -- > Brian S. Diggs, PhD > Senior Research Associate, Department of Surgery > Oregon Health & Science University > [[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] Changing legend to fill colour in ggplot
Hello R experts, I am having a problem to edit legend in ggplot using four variables. My data structure is : str(df) 'data.frame': 10 obs. of 6 variables: $ id: Factor w/ 2 levels "639A","640": 1 1 1 1 1 2 2 2 2 2 $ species : Factor w/ 5 levels "acinetobacter_sp",..: 2 5 1 4 3 2 5 1 4 3 $ genome_coverage_bp: int 8196 3405 8625 22568 2128 6100 1841 3914 8487 1064 $ genome_length : int 3571237 2541445 3912725 3479613 5460977 3571237 2541445 3912725 3479613 5460977 $ genome_coverage_percentage: Factor w/ 10 levels "0.02%","0.04%",..: 8 5 7 10 2 6 3 4 9 1 $ avg_depth_coverage: num 121.96 2.81 19.84 399.63 1.64 ... Now what I did is p=ggplot(df,aes(genome_coverage_percentage,avg_depth_coverage))+geom_point(aes(colour = species,shape = factor(id))) p+scale_shape_discrete(name ="",labels=c("Patient 1", "Patient 2")) That creats the plot below. But I want to change the circles of legend in fill colour. So that it doesn't look like it is only from Patient 1, as that also has circle. Can anybody help me please? Thanks a lot in advance :) Mitra [[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] Error with metaMDS
Dear Sarah, Thanks for your reply. But I don't have any site where all the species are 0. Is there anyway to calculate the dissimilarity between sites where it computes only the non-zero species values. Excluding all the zero event will result a big loss in species data. I don't want to delete the cases where may be 5out of 8 sites have species info, only 3 don't have. Should I replace zero with a very small number. What is the best thing to do in such cases? Thanks, Mitra On 24 June 2013 21:24, Sarah Goslee wrote: > Hi, > > What do you expect the dissimilarity between a site with no species > and a site with some species to be? > > If you want to use Bray-Curtis dissimilarity, you need to drop the > sites with no species, as the error message suggests. > > But if you can answer my first question, you may be able to select a > different dissimilarity metric that matches your expectations > numerically. > > Sarah > > > On Mon, Jun 24, 2013 at 7:33 AM, Suparna Mitra > wrote: > > H > > ello R-experts, > > I want to do ordination plots using vegan metaMDS. > > I have a where many cells have zero values. > > > > Data structure: > > X[1:10,1:14] > >Height.1 Height.2 Height.3 Height.4 Height.5 Height.6 Height.7 > > Height.8 Height.9 Height.10 Height.11 Height.12 Height.13 > > D30I1A 46000000 > > 00 039 098 > > D30I1B 46000000 > > 00 039 098 > > D30I1C 70000000 > > 00 0 085 0 > > D30I2A 47000000 > > 00 049 0 105 > > D30I2B 68000000 > > 00 083 0 214 > > D30I2C0 7500000 > > 00 0 083 0 > > D30I3A 48000000 > > 00 042 0 107 > > D30I3B 64000000 > > 00 072 0 177 > > D30I3C 72000000 > > 00 0 096 0 > > D30M1A 60000000 > > 00 074 0 169 > > > > Another data structure > >> Genus_data[1:10,1:14] > > Sample Acanthamoeba Acidianus Aegilops Alphapapillomavirus Asfivirus > > Brassica Buchnera Coprinellus Diaphorobacter Hartmannella Ignicoccus > > 1HS1_S10 00 0 0 > > 00 0 00 0 > > 2HS2_S20 11 0 0 > > 00 0 01 0 > > 3HS3_S30 00 1 0 > > 01 1 10 0 > > 4HS4_S40 00 0 1 > > 00 0 00 0 > > 5 HS13_S50 00 0 0 > > 00 0 00 0 > > 6 HS14_S60 00 0 0 > > 10 0 00 0 > > 7 HS15_S70 00 0 0 > > 00 0 00 0 > > 8 HS16_S80 00 0 0 > > 00 0 00 1 > > 9 HS25_S91 00 0 0 > > 00 0 00 0 > > > > I am having two different kind of errors for these two data... > > Error 1 > >> ord1 <- metaMDS( > > X > > ="bray") > > Square root transformation > > Wisconsin double standardization > > Error in if (any(dist < -sqrt(.Machine$double.eps))) warning("some > > dissimilarities are negative -- is this intentional?") : > > missing value where TRUE/FALSE neede
[R] Error with metaMDS
H ello R-experts, I want to do ordination plots using vegan metaMDS. I have a where many cells have zero values. Data structure: X[1:10,1:14] Height.1 Height.2 Height.3 Height.4 Height.5 Height.6 Height.7 Height.8 Height.9 Height.10 Height.11 Height.12 Height.13 D30I1A 46000000 00 039 098 D30I1B 46000000 00 039 098 D30I1C 70000000 00 0 085 0 D30I2A 47000000 00 049 0 105 D30I2B 68000000 00 083 0 214 D30I2C0 7500000 00 0 083 0 D30I3A 48000000 00 042 0 107 D30I3B 64000000 00 072 0 177 D30I3C 72000000 00 0 096 0 D30M1A 60000000 00 074 0 169 Another data structure > Genus_data[1:10,1:14] Sample Acanthamoeba Acidianus Aegilops Alphapapillomavirus Asfivirus Brassica Buchnera Coprinellus Diaphorobacter Hartmannella Ignicoccus 1HS1_S10 00 0 0 00 0 00 0 2HS2_S20 11 0 0 00 0 01 0 3HS3_S30 00 1 0 01 1 10 0 4HS4_S40 00 0 1 00 0 00 0 5 HS13_S50 00 0 0 00 0 00 0 6 HS14_S60 00 0 0 10 0 00 0 7 HS15_S70 00 0 0 00 0 00 0 8 HS16_S80 00 0 0 00 0 00 1 9 HS25_S91 00 0 0 00 0 00 0 I am having two different kind of errors for these two data... Error 1 > ord1 <- metaMDS( X ="bray") Square root transformation Wisconsin double standardization Error in if (any(dist < -sqrt(.Machine$double.eps))) warning("some dissimilarities are negative -- is this intentional?") : missing value where TRUE/FALSE needed In addition: Warning messages: 1: In distfun(comm, method = distance, ...) : you have empty rows: their dissimilarities may be meaningless in method bray 2: In distfun(comm, method = distance, ...) : missing values in results Error 2 ord.data= metaMDS(data, distance="bray") Error in if (any(autotransform, noshare > 0, wascores) && any(comm < 0)) { : missing value where TRUE/FALSE needed In addition: Warning message: In Ops.factor(left, right) : < not meaningful for factors I searched all the details of metaMDS where it is suggested to avail the argument 'zerodist' So I tried both X.dist1 <- metaMDSdist(X, method="bray",zerodist = "ignore") X.dist2 <- metaMDSdist(X, method="bray",zerodist = "add") Can Please help me with this. Thanks, Mitra [[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] Fwd: metaMDS Error, Nan similar or negative values
Hello R experts and Vegan users, I am re-posting my msg as I didn't get any reply. I am not sure if it was not sent properly. Please help. Sorry for repeated post. I want to do ordination plots using vegan metaMDS. I have a where many cells have zero values. Data structure: X[1:10,1:14] Height.1 Height.2 Height.3 Height.4 Height.5 Height.6 Height.7 Height.8 Height.9 Height.10 Height.11 Height.12 Height.13 D30I1A 46000000 00 039 098 D30I1B 46000000 00 039 098 D30I1C 70000000 00 0 085 0 D30I2A 47000000 00 049 0 105 D30I2B 68000000 00 083 0 214 D30I2C0 7500000 00 0 083 0 D30I3A 48000000 00 042 0 107 D30I3B 64000000 00 072 0 177 D30I3C 72000000 00 0 096 0 D30M1A 60000000 00 074 0 169 When I tried to perform metaMDS, it was not working, with the error > ord1 <- metaMDS( X ="bray") Square root transformation Wisconsin double standardization Error in if (any(dist < -sqrt(.Machine$double.eps))) warning("some dissimilarities are negative -- is this intentional?") : missing value where TRUE/FALSE needed In addition: Warning messages: 1: In distfun(comm, method = distance, ...) : you have empty rows: their dissimilarities may be meaningless in method bray 2: In distfun(comm, method = distance, ...) : missing values in results I realised some of the values are either zero or similar. I tried to check it with distance X .dist <- metaMDSdist( X , method="bray") got the error: Square root transformation Wisconsin double standardization Error in distfun(comm, method = distance, ...) : formal argument "method" matched by multiple actual arguments When I checked the distance I see some of the distances are NaN as for example some rows of dist matrix: D3M1A NaN 1.0 1.0 1.0 1.0 1.0 NaN 1.0 1.0 NaN D3R1A NaN 1.0 1.0 1.0 1.0 1.0 NaN 1.0 1.0 NaN I searched all the details of metaMDS where it is suggested to avail the argument 'zerodist' So I tried both X.dist1 <- metaMDSdist(X, method="bray",zerodist = "ignore") X.dist2 <- metaMDSdist(X, method="bray",zerodist = "add") But for both the cases I still have those NaN values in some distances. I have read, one of the discussion says modify zero dissimilarities as: If there is a good reason, and you want to include all samples, then you'll need to come up with a means for handling them. metaMDSdist allow you to add a small value to the zero dissimilarities. The details are in the code, but effectively all zero distances are replaced by half the smallest non zero distance. You could do a similar replacement yourself if you feel this is warranted and/or justified. minDij <- min(Dij[Dij > 0) / 2 Dij[Dij <= 0] <- minDij But still I don't understand how can I modify the NaN values. In my data I don't have any NA values. All the cells are either +ve or zero. Please help me with this. Should I just replace all the NaN values with zero? Please advice. Thanks a lot, Mitra [[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] metaMDS Error, Nan similar or negative values
H ello R-experts, I want to do ordination plots using vegan metaMDS. I have a where many cells have zero values. Data structure: X[1:10,1:14] Height.1 Height.2 Height.3 Height.4 Height.5 Height.6 Height.7 Height.8 Height.9 Height.10 Height.11 Height.12 Height.13 D30I1A 46000000 00 039 098 D30I1B 46000000 00 039 098 D30I1C 70000000 00 0 085 0 D30I2A 47000000 00 049 0 105 D30I2B 68000000 00 083 0 214 D30I2C0 7500000 00 0 083 0 D30I3A 48000000 00 042 0 107 D30I3B 64000000 00 072 0 177 D30I3C 72000000 00 0 096 0 D30M1A 60000000 00 074 0 169 When I tried to perform metaMDS, it was not working, with the error > ord1 <- metaMDS( X ="bray") Square root transformation Wisconsin double standardization Error in if (any(dist < -sqrt(.Machine$double.eps))) warning("some dissimilarities are negative -- is this intentional?") : missing value where TRUE/FALSE needed In addition: Warning messages: 1: In distfun(comm, method = distance, ...) : you have empty rows: their dissimilarities may be meaningless in method bray 2: In distfun(comm, method = distance, ...) : missing values in results I realised some of the values are either zero or similar. I tried to check it with distance X .dist <- metaMDSdist( X , method="bray") got the error: Square root transformation Wisconsin double standardization Error in distfun(comm, method = distance, ...) : formal argument "method" matched by multiple actual arguments When I checked the distance I see some of the distances are NaN as for example some rows of dist matrix: D3M1A NaN 1.0 1.0 1.0 1.0 1.0 NaN 1.0 1.0 NaN D3R1A NaN 1.0 1.0 1.0 1.0 1.0 NaN 1.0 1.0 NaN I searched all the details of metaMDS where it is suggested to avail the argument 'zerodist' So I tried both X.dist1 <- metaMDSdist(X, method="bray",zerodist = "ignore") X.dist2 <- metaMDSdist(X, method="bray",zerodist = "add") But for both the cases I still have those NaN values in some distances. I have read, one of the discussion says modify zero dissimilarities as: If there is a good reason, and you want to include all samples, then you'll need to come up with a means for handling them. metaMDSdist allow you to add a small value to the zero dissimilarities. The details are in the code, but effectively all zero distances are replaced by half the smallest non zero distance. You could do a similar replacement yourself if you feel this is warranted and/or justified. minDij <- min(Dij[Dij > 0) / 2 Dij[Dij <= 0] <- minDij But still I don't understand how can I modify the NaN values. In my data I don't have any NA values. All the cells are either +ve or zero. Please help me with this. Should I just replace all the NaN values with zero? Please advice. Thanks a lot, Mitra [[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 define desired numbers to a vector based on the present numbers
Yes I have already changed that as this was only a small vector, my real vector is quite big.. thanks a ton. Bets wishes, Mitra On 21 June 2013 23:43, Clint Bowman wrote: > I suspect the OP may want > > rep(1:length(unique(x)), rle(x[order(x)])$lengths)[**order(order(x))] > > to allow for variable numbers of unique values. > > Clint > > Clint BowmanINTERNET: cl...@ecy.wa.gov > Air Quality Modeler INTERNET: cl...@math.utah.edu > Department of Ecology VOICE: (360) 407-6815 > PO Box 47600FAX:(360) 407-7534 > Olympia, WA 98504-7600 > > USPS: PO Box 47600, Olympia, WA 98504-7600 > Parcels:300 Desmond Drive, Lacey, WA 98503-1274 > > > On Fri, 21 Jun 2013, Rui Barradas wrote: > > Hello, >> >> I'm not sure I understand. You want to attribute a color number 1:7 to >> each element of your vector? Maybe the following will do. >> >> >> x <- scan(text = " >> 43 43 43 43 0 39 13 39 50 39 39 23 23 32 0 13 32 23 32 23 0 13 13 0 >> ") >> >> cols <- rep(1:7, rle(x[order(x)])$lengths)[**order(order(x))] >> plot(x, col = cols) >> >> >> Hope this helps, >> >> Rui Barradas >> >> Em 21-06-2013 16:13, Suparna Mitra escreveu: >> >>> Hello R experts, >>>I want to define desired numbers to a vector based on the present >>> numbers. Can anybody please help me? >>> Obviously I found worst ways to do it, but I believe there must be any >>> better way. >>> >>> I have vector as >>> >>>> X >>>> >>> [1] 43 43 43 43 0 39 13 39 50 39 39 23 23 32 0 13 32 23 32 23 0 13 >>> 13 0 >>> Now I want to colour a plot with unic cols based on this vector. I want >>> to >>> baseplot. >>> But now the problem in normal col pallet these nos has repetition. Thus I >>> tried to >>> library(RColorBrewer) >>> >>>> coll<-colorRampPalette(brewer.**pal(9, "Set1"))(50) >>>> >>> and then use this vector as col. >>> >>> But there also the colours are not enough bright. >>> >>> So I am trying to set new a vector reading this present vector. >>> Obviously I can type out manually as >>> coll=c(rep(1,4),0,2 >>> >>> But rather I am trying for some automation with which function or similar >>> But still now I am struggling with this. >>> Can anybody please help me. >>> >>> Basic thing is some way to reads the vector and define a new col vector >>> from 1:7 >>> >>> Thanks a lot, >>> Mitra >>> >>> [[alternative HTML version deleted]] >>> >>> __** >>> R-help@r-project.org mailing list >>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help> >>> PLEASE do read the posting guide http://www.R-project.org/** >>> posting-guide.html <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<https://stat.ethz.ch/mailman/listinfo/r-help> >> PLEASE do read the posting guide http://www.R-project.org/** >> posting-guide.html <http://www.R-project.org/posting-guide.html> >> and provide commented, minimal, self-contained, reproducible code. >> >> [[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 define desired numbers to a vector based on the present numbers
Thanks a lot Rui, It helps :) I can modify this according to my need.. I didn't know about rle function. Thanks again, Mitra On 21 June 2013 23:32, Rui Barradas wrote: > Hello, > > I'm not sure I understand. You want to attribute a color number 1:7 to > each element of your vector? Maybe the following will do. > > > x <- scan(text = " > > 43 43 43 43 0 39 13 39 50 39 39 23 23 32 0 13 32 23 32 23 0 13 13 0 > ") > > cols <- rep(1:7, rle(x[order(x)])$lengths)[**order(order(x))] > plot(x, col = cols) > > > Hope this helps, > > Rui Barradas > > Em 21-06-2013 16:13, Suparna Mitra escreveu: > >> Hello R experts, >>I want to define desired numbers to a vector based on the present >> numbers. Can anybody please help me? >> Obviously I found worst ways to do it, but I believe there must be any >> better way. >> >> I have vector as >> >>> X >>> >> [1] 43 43 43 43 0 39 13 39 50 39 39 23 23 32 0 13 32 23 32 23 0 13 >> 13 0 >> Now I want to colour a plot with unic cols based on this vector. I want to >> baseplot. >> But now the problem in normal col pallet these nos has repetition. Thus I >> tried to >> library(RColorBrewer) >> >>> coll<-colorRampPalette(brewer.**pal(9, "Set1"))(50) >>> >> and then use this vector as col. >> >> But there also the colours are not enough bright. >> >> So I am trying to set new a vector reading this present vector. >> Obviously I can type out manually as >> coll=c(rep(1,4),0,2 >> >> But rather I am trying for some automation with which function or similar >> But still now I am struggling with this. >> Can anybody please help me. >> >> Basic thing is some way to reads the vector and define a new col vector >> from 1:7 >> >> Thanks a lot, >> Mitra >> >> [[alternative HTML version deleted]] >> >> __** >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help> >> PLEASE do read the posting guide http://www.R-project.org/** >> posting-guide.html <http://www.R-project.org/posting-guide.html> >> and provide commented, minimal, self-contained, reproducible code. >> >> [[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 define desired numbers to a vector based on the present numbers
Hello R experts, I want to define desired numbers to a vector based on the present numbers. Can anybody please help me? Obviously I found worst ways to do it, but I believe there must be any better way. I have vector as > X [1] 43 43 43 43 0 39 13 39 50 39 39 23 23 32 0 13 32 23 32 23 0 13 13 0 Now I want to colour a plot with unic cols based on this vector. I want to baseplot. But now the problem in normal col pallet these nos has repetition. Thus I tried to library(RColorBrewer) > coll<-colorRampPalette(brewer.pal(9, "Set1"))(50) and then use this vector as col. But there also the colours are not enough bright. So I am trying to set new a vector reading this present vector. Obviously I can type out manually as coll=c(rep(1,4),0,2 But rather I am trying for some automation with which function or similar But still now I am struggling with this. Can anybody please help me. Basic thing is some way to reads the vector and define a new col vector from 1:7 Thanks a lot, Mitra [[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 add any extra word to existing column heading in R
Hello, I was trying ways to define new column names. Or very traditional way to export the data and add names in excel. But thought there must a way, but searched with several key words in forum, but couldn't find the exact what I mean. May be my search terms are not perfect. Thanks, Mitra On 20 June 2013 13:04, Pascal Oettli wrote: > Hello, > > What did you try to do by yourself before to ask? > > Regards, > Pascal > > > > On 20/06/13 13:56, Suparna Mitra wrote: > >> Hello R experts, >>I want to add some extra words to number to existing column header. Can >> anybody tell me how to do that. >> >> e.g. if I have a data.frame >>Height.1 Height.2 Height.6 Height.8 Height.10 Height.11 Height.17 >> Height.20 Height.22 Height.31 >> MBR174 720 104 0 250 144 >> 0 0 0 >> MBR2 0 940 150 0 250 158 >> 0 0 0 >> MBR393 1670 199 0 250 208 >> 0 0 0 >> MBR4 146 1060 165 0 250 135 >> 0 0 0 >> MBR5 149 10600 0 250 141 >> 0 0 0 >> MBR6 12000 97 0 250 175 >> 0 0 0 >> MBR7 12000 76 145 250 130 >> 0 079 >> MBR889 700 114 0 250 211 >> 0 0 0 >> >> I want to rename the heading as >> >>Height.1.D1 Height.2.D1 Height.6.D1 Height.8.D1 Height.10.D1 >> Height.11.D1 Height.17.D1 Height.20.D1 Height.22.D1 Height.31.D1 >> MBR174 720 104 0 250 144 >> 0 0 0 >> MBR2 0 940 150 0 250 158 >> 0 0 0 >> MBR393 1670 199 0 250 208 >> 0 0 0 >> MBR4 146 1060 165 0 250 135 >> 0 0 0 >> MBR5 149 10600 0 250 141 >> 0 0 0 >> MBR6 12000 97 0 250 175 >> 0 0 0 >> MBR7 12000 76 145 250 130 >> 0 079 >> MBR889 700 114 0 250 211 >> 0 0 0 >> MBR9 168000 0 250 137 >> 0 0 0 >> MBR11 78 680 117 0 250 161 >> 049 0 >> >> Any help will be really great. >> Thanks, >> Mitra >> >> [[alternative HTML version deleted]] >> >> __** >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help> >> PLEASE do read the posting guide http://www.R-project.org/** >> posting-guide.html <http://www.R-project.org/posting-guide.html> >> and provide commented, minimal, self-contained, reproducible code. >> >> [[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 add any extra word to existing column heading in R
Hello R experts, I want to add some extra words to number to existing column header. Can anybody tell me how to do that. e.g. if I have a data.frame Height.1 Height.2 Height.6 Height.8 Height.10 Height.11 Height.17 Height.20 Height.22 Height.31 MBR174 720 104 0 250 144 0 0 0 MBR2 0 940 150 0 250 158 0 0 0 MBR393 1670 199 0 250 208 0 0 0 MBR4 146 1060 165 0 250 135 0 0 0 MBR5 149 10600 0 250 141 0 0 0 MBR6 12000 97 0 250 175 0 0 0 MBR7 12000 76 145 250 130 0 079 MBR889 700 114 0 250 211 0 0 0 I want to rename the heading as Height.1.D1 Height.2.D1 Height.6.D1 Height.8.D1 Height.10.D1 Height.11.D1 Height.17.D1 Height.20.D1 Height.22.D1 Height.31.D1 MBR174 720 104 0 250 144 0 0 0 MBR2 0 940 150 0 250 158 0 0 0 MBR393 1670 199 0 250 208 0 0 0 MBR4 146 1060 165 0 250 135 0 0 0 MBR5 149 10600 0 250 141 0 0 0 MBR6 12000 97 0 250 175 0 0 0 MBR7 12000 76 145 250 130 0 079 MBR889 700 114 0 250 211 0 0 0 MBR9 168000 0 250 137 0 0 0 MBR11 78 680 117 0 250 161 049 0 Any help will be really great. Thanks, Mitra [[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] Creating subset using selected columns
Hello R experts, I need a help to create a subset file. I know with subset comand, its very easy to select many different columns, or threshold. But here I have a bit problem as in my data file is big. And I don't want to identify the column numbers or names manually. I am trying to find any way to automatise this. For example I have a file with about 1500 columns from TRFLP intensity data. And the column names are like: [1] "Sample.Name""Marker" "RE" "Dye" "Allele.1" "Size.1" "Height.1" "Peak.Area.1" "Data.Point.1" [10] "Allele.2" "Size.2" "Height.2" "Peak.Area.2" "Data.Point.2" "Allele.3" "Size.3" "Height.3" "Peak.Area.3" [19] "Data.Point.3" "Allele.4" "Size.4" "Height.4" "Peak.Area.4""Data.Point.4" "Allele.5" "Size.5" "Height.5" [28] "Peak.Area.5""Data.Point.5" "Allele.6" "Size.6" "Height.6" "Peak.Area.6""Data.Point.6" "Allele.7" "Size.7" [37] "Height.7" "Peak.Area.7""Data.Point.7" "Allele.8" "Size.8" "Height.8" "Peak.Area.8""Data.Point.8" "Allele.9" [46] "Size.9" "Height.9" "Peak.Area.9""Data.Point.9" "Allele.10" "Size.10""Height.10" "Peak.Area.10" "Data.Point.10" . Suppose I want to create a subset selecting all the columns with name Peak.Area (as in unix Peak.Area.*) How can I do that in R? Thanks a lot for the help. Best wishes, Mitra [[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] Rplot save problem after using "identify" with R version 3.0.0
Hello R experts, I am having an wired problem to save my RPlot after I use "identify" option. Points are identified properly, but when I try to save that image I get error as: " Error: first argument must be a string (of length 1) or native symbol reference" and the image without identified points are saved. I am having this problem after I upgraded to R version 3.0.0. (Mac). My system is OS X 10.8.3 >From the R consol: > identify(ord.genus$points,labels=names,cex = .5, col = "dark red") # particular data samples identified with names [1] 1 2 3 4 5 12 14 24 25 26 27 28 29 30 31 32 34 #identified properly. > Error: first argument must be a string (of length 1) or native symbol reference #This error appears after I try to save the image. Any help will be really great. Thanks, Mitra [[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] Using loop for applying function on matrix
Thanks a lot for all your help. best wishes, Mitra On 21 May 2013 21:04, arun wrote: > You could also use: > > sapply(seq_len(ncol(mdat)),function(i) mdat[,i]*100/x[i]) > # [,1] [,2] [,3] [,4] [,5] > #[1,] 7.142857 13.3 30 36.36364 27.8 > #[2,] 78.571429 80.0 130 90.90909 55.6 > #[3,] 14.285714 20.0 40 45.45455 33.3 > #[4,] 71.428571 60.0 80 81.81818 55.6 > #[5,] 35.714286 40.0 70 72.72727 22.2 > A.K. > > - Original Message - > From: Suparna Mitra > To: Pascal Oettli > Cc: r-help@r-project.org > Sent: Tuesday, May 21, 2013 5:19 AM > Subject: Re: [R] Using loop for applying function on matrix > > Thanks for your reply Pascal. > I am presently using it with sweep. But here in the question I just gave > one simple example. In reality I need several functions to run. Thus I > was wondering, if without sweep, I can use loop. Also want to learn how to > do this using loop. > Any help will be really great, > Thanks, > Mitra > > Dr. Suparna Mitra > Department of Molecular and Clinical Pharmacology > Institute of Translational Medicine University of Liverpool > Block A: Waterhouse Buildings > 1-5 Brownlow Street > Liverpool > L69 3GL > > Tel. +44 (0)151 795 5414 > M: +44 (0) 7523228621 > Internal ext: 55401 > > > > On 21 May 2013 16:29, Pascal Oettli wrote: > > > Hi, > > > > ?sweep > > > > mdat <- matrix(c(1,11,2,10,5,2,12,3,9,**6,3,13,4,8,7,4,10,5,9,8,5,10,** > > 6,10,4),5,5) > > x <- c(14,15,10,11,18) > > > > sweep(mdat*100, 2, x, FUN='/') > > > > [,1] [,2] [,3] [,4] [,5] > > [1,] 7.142857 13.3 30 36.36364 27.8 > > [2,] 78.571429 80.0 130 90.90909 55.6 > > [3,] 14.285714 20.0 40 45.45455 33.3 > > [4,] 71.428571 60.0 80 81.81818 55.6 > > [5,] 35.714286 40.0 70 72.72727 22.2 > > > > Hope this helps, > > Pascal > > > > > > > > On 05/21/2013 04:16 PM, Suparna Mitra wrote: > > > >> Hello R Experts, > >>I need a bit of help in using loop. > >> I have a matrix onto which I need to use several functions. > >> > >> In a simplified form suppose my matrix is > >> > >>> mdat > >>> > >> [,1] [,2] [,3] [,4] [,5] > >> [1,]12345 > >> [2,] 11 12 13 10 10 > >> [3,]23456 > >> [4,] 10989 10 > >> [5,]56784 > >> > >> And I have one vector > >> > >>> x > >>> > >> [1] 14 15 10 11 18 > >> > >> Now suppose in simple form I want to create a matrix in which each col > >> value will be divided with consecutive no from vector x. For example > >> > >> column 1 of new vector will be C1=mdat[,1]*100/x[1] > >> > >> C1 > >>> > >> [1] 7.142857 78.571429 14.285714 71.428571 35.714286 > >> > >> Now how can I use the loop to have the complete vector at a time? > >> I tried something like this, but in vain. > >> for(i in 1:5) { > >> Data=(mdat[,i]*100/x[i], add=T) > >> } > >> > >> Any help will be really great. > >> Thanks, > >> Mitra > >> > >> [[alternative HTML version deleted]] > >> > >> __** > >> R-help@r-project.org mailing list > >> https://stat.ethz.ch/mailman/**listinfo/r-help< > https://stat.ethz.ch/mailman/listinfo/r-help> > >> PLEASE do read the posting guide http://www.R-project.org/** > >> posting-guide.html <http://www.R-project.org/posting-guide.html> > >> and provide commented, minimal, self-contained, reproducible code. > >> > >> > > [[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. > > [[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] Using loop for applying function on matrix
Thanks for your reply Pascal. I am presently using it with sweep. But here in the question I just gave one simple example. In reality I need several functions to run. Thus I was wondering, if without sweep, I can use loop. Also want to learn how to do this using loop. Any help will be really great, Thanks, Mitra Dr. Suparna Mitra Department of Molecular and Clinical Pharmacology Institute of Translational Medicine University of Liverpool Block A: Waterhouse Buildings 1-5 Brownlow Street Liverpool L69 3GL Tel. +44 (0)151 795 5414 M: +44 (0) 7523228621 Internal ext: 55401 On 21 May 2013 16:29, Pascal Oettli wrote: > Hi, > > ?sweep > > mdat <- matrix(c(1,11,2,10,5,2,12,3,9,**6,3,13,4,8,7,4,10,5,9,8,5,10,** > 6,10,4),5,5) > x <- c(14,15,10,11,18) > > sweep(mdat*100, 2, x, FUN='/') > > [,1] [,2] [,3] [,4] [,5] > [1,] 7.142857 13.3 30 36.36364 27.8 > [2,] 78.571429 80.0 130 90.90909 55.6 > [3,] 14.285714 20.0 40 45.45455 33.3 > [4,] 71.428571 60.0 80 81.81818 55.6 > [5,] 35.714286 40.0 70 72.72727 22.2 > > Hope this helps, > Pascal > > > > On 05/21/2013 04:16 PM, Suparna Mitra wrote: > >> Hello R Experts, >>I need a bit of help in using loop. >> I have a matrix onto which I need to use several functions. >> >> In a simplified form suppose my matrix is >> >>> mdat >>> >> [,1] [,2] [,3] [,4] [,5] >> [1,]12345 >> [2,] 11 12 13 10 10 >> [3,]23456 >> [4,] 10989 10 >> [5,]56784 >> >> And I have one vector >> >>> x >>> >> [1] 14 15 10 11 18 >> >> Now suppose in simple form I want to create a matrix in which each col >> value will be divided with consecutive no from vector x. For example >> >> column 1 of new vector will be C1=mdat[,1]*100/x[1] >> >> C1 >>> >> [1] 7.142857 78.571429 14.285714 71.428571 35.714286 >> >> Now how can I use the loop to have the complete vector at a time? >> I tried something like this, but in vain. >> for(i in 1:5) { >> Data=(mdat[,i]*100/x[i], add=T) >> } >> >> Any help will be really great. >> Thanks, >> Mitra >> >> [[alternative HTML version deleted]] >> >> __** >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help> >> PLEASE do read the posting guide http://www.R-project.org/** >> posting-guide.html <http://www.R-project.org/posting-guide.html> >> and provide commented, minimal, self-contained, reproducible code. >> >> [[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] Using loop for applying function on matrix
Hello R Experts, I need a bit of help in using loop. I have a matrix onto which I need to use several functions. In a simplified form suppose my matrix is > mdat [,1] [,2] [,3] [,4] [,5] [1,]12345 [2,] 11 12 13 10 10 [3,]23456 [4,] 10989 10 [5,]56784 And I have one vector > x [1] 14 15 10 11 18 Now suppose in simple form I want to create a matrix in which each col value will be divided with consecutive no from vector x. For example column 1 of new vector will be C1=mdat[,1]*100/x[1] > C1 [1] 7.142857 78.571429 14.285714 71.428571 35.714286 Now how can I use the loop to have the complete vector at a time? I tried something like this, but in vain. for(i in 1:5) { Data=(mdat[,i]*100/x[i], add=T) } Any help will be really great. Thanks, Mitra [[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] Problem with ordiellipse coloured factor in Vegan
Hello R experts, I am trying to plot ordiellipse for my data but the col according to factors. Metabolites_raw= read.csv(file.choose(), head = TRUE) #file 21Metabolites.csv Metabolites_t=t(Metabolites_raw[,2:82]) ord <- metaMDS(Metabolites_t, distance="bray") symbol=as.numeric(Metab_metadata$LandType) col.list <- c("red","slategray","seagreen","cyan","pink","brown","black", "blue","yellow","magenta") palette(col.list) plot(ord$points, col = Metab_metadata$Day+2,pch=symbol, xlim=c(-0.3,0.35)) legend(.28,.25, c("0", "8", "16"),fill = c(2, 10,18)) # draw dispersion ellipses around data points groupz <-c(2,10,18) for(i in seq(groupz)) { ordiellipse(ord, Metab_metadata$Day, kind = "sd", label = T,col=groupz[i], show.groups=groupz[i]) } Now here I get the error Error in text.default(...) : no coordinates were supplied (But sometimes same code works. I am not sure what am I doing wrong.) Data files are attached. Any help will be really great. Thanks, Mitra __ 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] NMDS using Vegan
Dear Prof. Simpson, Thanks a lot for your reply. Yes I know that I can change the labels any time, but I was only worried if I am doing any mistake as default output didn't match with the output shown in the Vegan tutorial output. Thanks, Mitra On 15 May 2013 22:43, Gavin Simpson wrote: > On Wed, 2013-05-15 at 12:06 +0800, Suparna Mitra wrote: >> Hello R experts, >> I am new to Vegan and use trying to follow the tutorial to perform NMDS >> for my data. But after performing the metaMDS, when I plotted my results >> the default plot shows MDS1 vs MDS2. Thought according to the >> tutorial Default ordination plot should display NMDS1vs NMDS2. Why is this >> difference? Accourding to tutorial it says: Function metaMDS >> is a wrapper to perform NMDS. >> Can anybody please help me to understand this? >> Thanks, >> Mitra > > They are just labels and metaMDS **has** performed an NMDS. Not sure why > Jari labelled these as "MDSx". If this bothers you so, add your own > labels: > > require("vegan") > data(dune) > sol <- metaMDS(dune) > plot(sol, xlab = "NMDS1", ylab = "NMDS2") > > HTH > > G > > -- > Gavin Simpson, PhD [t] +1 306 337 8863 > Adjunct Professor, Department of Biology[f] +1 306 337 2410 > Institute of Environmental Change & Society [e] gavin.simp...@uregina.ca > 523 Research and Innovation Centre [tw] @ucfagls > University of Regina > Regina, SK S4S 0A2, Canada > > > __ 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] NMDS using Vegan
Hello R experts, I am new to Vegan and use trying to follow the tutorial to perform NMDS for my data. But after performing the metaMDS, when I plotted my results the default plot shows MDS1 vs MDS2. Thought according to the tutorial Default ordination plot should display NMDS1vs NMDS2. Why is this difference? Accourding to tutorial it says: Function metaMDS is a wrapper to perform NMDS. Can anybody please help me to understand this? Thanks, Mitra [[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] Error is assocplot
Hello, I have a contingency table showing relation between two datasets. I tried to see association among them with the assocplot, but it shows error. mosaicplot of the same data worked perfectly. Can anyone please help me. Con.table=as.matrix(Con.table) > dim(Con.table) [1] 27 27 > assocplot(Con.table,space = 0.3, + main = NULL, xlab = NULL, ylab = NULL) Error in plot.window(xlim, ylim, log = "") : need finite 'ylim' values And also I would like to know if I can use jaccard measure from the same contingency table. Thank you very much in advance, Best wishes, Mitra. [[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] Creating a symmetric contingency table from two vectors with different length of levels in R
Dear Andrija, Thank you very much for your quick reply. It looks like working. Thanks again, Suparna. On Wed, Apr 6, 2011 at 2:11 PM, andrija djurovic wrote: > Hi: > > Here is one solution: > > a<-factor(c(1,2,4,5,6)) > b<-factor(c(2,2,4,5,5)) > b1<-factor(b,levels=c(levels(b),levels(a)[levels(a)%in%levels(b)==FALSE])) > table(a,b1) > > but be aware that levels of b is a subset of levels of a. > > Andrija > > On Wed, Apr 6, 2011 at 10:39 AM, suparna mitra < > mi...@informatik.uni-tuebingen.de> wrote: > >> Hello, >> How can I create a symmetric contingency table from two categorical >> vectors >> having different length of levels? >> For example one vector has 98 levels >> TotalData1$Taxa.1 >> [1] "Aconoidasida" "Actinobacteria (class)" >> "Actinopterygii" "Alphaproteobacteria" >> [5] "Amoebozoa""Amphibia" >> "Anthozoa" "Aquificae (class)" >> and so on . >> 98 Levels: Aconoidasida Actinobacteria (class) >> >> and the other vector has 105 levels >> TotalData1$Taxa.2 >>[1] FlavobacteriaProteobacteria >> Bacteroidetes/Chlorobi group Bacteria >>[5] EpsilonproteobacteriaEpsilonproteobacteria >> Epsilonproteobacteria >> and so on .. >> 105 Levels: Acidobacteria Aconoidasida Actinobacteria (class) >> >> Now I want to create a symmetric contingency table. >> Any quick idea will be really helpful. >> Best regards, >> Mitra >> >>[[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<http://www.r-project.org/posting-guide.html> >> and provide commented, minimal, self-contained, reproducible code. >> > > [[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] Creating a symmetric contingency table from two vectors with different length of levels in R
Hello, How can I create a symmetric contingency table from two categorical vectors having different length of levels? For example one vector has 98 levels TotalData1$Taxa.1 [1] "Aconoidasida" "Actinobacteria (class)" "Actinopterygii" "Alphaproteobacteria" [5] "Amoebozoa""Amphibia" "Anthozoa" "Aquificae (class)" and so on . 98 Levels: Aconoidasida Actinobacteria (class) and the other vector has 105 levels TotalData1$Taxa.2 [1] FlavobacteriaProteobacteria Bacteroidetes/Chlorobi group Bacteria [5] EpsilonproteobacteriaEpsilonproteobacteria Epsilonproteobacteria and so on .. 105 Levels: Acidobacteria Aconoidasida Actinobacteria (class) Now I want to create a symmetric contingency table. Any quick idea will be really helpful. Best regards, Mitra [[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] ticklabs in scatterplot3d
Hello, I am having a problem to control ticklabs in scatterplot3d. When I am using it for small data then it is working fine. But with my big data all the labels are misplaced (one upon another). For example see the code below (I have just modified the scatterplot3d example to show my problem ). == my.mat <- matrix(runif(625), nrow=25) dimnames(my.mat) <- list(LETTERS[1:25], letters[1:25]) my.mat # this matrix I want to plot with the all 25 ticklabs scatterplot3d(s3d.dat, type="h", lwd=1, pch=" ",x.ticklabs=colnames(my.mat), y.ticklabs=rownames(my.mat)) == I want all 25 labels to be written in y.ticklabs Can anyone please help me? Thank you very much, Suparna. [[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] Problem in 'Apply' function: does anybody have other solution
Dear All, Just to add some more lines in my previous query I am writing this. I was checking with several data. The cases where the apply function is working, the part of result looks like : > apply(Species.all[1:10,],1,max,na.rm=TRUE) 1 2 3 4 5 6 7 8 910 22392454545142525 753 10110 and with the problematic data it looks like: > apply(Species.all[1:10,],1,max,na.rm=TRUE) 1 2 3 4 5 6 7 8 9 10 "7286" "3258" "1024" " 45" " 45" " 45" " 9" " 25" " 25" " 753" But my all the datasets are in CSV format. I am reading those datasets as read.csv or read.delim Can anybody please suggest me how to this problem? Thanks and regards, Suparna. On Wed, Jun 17, 2009 at 1:14 PM, suparna mitra wrote: > Dear All, > I am having some problem in apply function. > I have some data like below. I want to get a range vector (which is max-min > value for each row , ignoring NA values.) > > Species.all[1:10,] >V2 V3 V4 V5V6 V7V8 V9 > 1 57543 55938 47175 54922 36032 5785 29497 7286 > 2 42364 40472 29887 40107 19723 2691 14445 3258 > 3 19461 19646 18538 22392 6744 794 4919 1024 > 4 45 41 28 3433 NA26 NA > 5 45 41 28 3433 NA26 NA > 6 45 41 28 3433 NA26 NA > 7 14 9 14 14 7 NA10 NA > 8 20 25 10 1521 NA10 NA > 9 20 25 10 1521 NA10 NA > 10578566478753 361 150 262 170 > > dim(Species.all) > [1] 18628 > > I used apply function like below. I used this same function for some other > data, there it worked. But here its not working (giving error message). > > > Range.j=apply(Species.all,1,max,na.rm = > TRUE)-apply(Species.all,1,min,na.rm = TRUE) > Error in apply(Species.all, 1, max, na.rm = TRUE) - apply(Species.all, : > non-numeric argument to binary operator > > When i tried to check, you can see from the steps it is giving totally > wrong results. > > > apply(Species.all[1:10,],1,max) > 1 2 3 4 5 6 7 8 9 10 > "7286" "3258" "1024" NA NA NA NA NA NA " 753" > > apply(Species.all[1:10,],1,min) >1234567 > 89 10 > " 47175" " 29887" " 18538" NA NA NA NA > NA NA " 262" > > > Main problem is, this code is working for some cases, but not for all. Does > any body have an idea, why it is so? Or can anyone show me some other way to > do the same. > Thanks in advance, > With best regard, > Suparna > [[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] Problem in 'Apply' function: does anybody have other solution
Dear All, I am having some problem in apply function. I have some data like below. I want to get a range vector (which is max-min value for each row , ignoring NA values.) > Species.all[1:10,] V2 V3 V4 V5V6 V7V8 V9 1 57543 55938 47175 54922 36032 5785 29497 7286 2 42364 40472 29887 40107 19723 2691 14445 3258 3 19461 19646 18538 22392 6744 794 4919 1024 4 45 41 28 3433 NA26 NA 5 45 41 28 3433 NA26 NA 6 45 41 28 3433 NA26 NA 7 14 9 14 14 7 NA10 NA 8 20 25 10 1521 NA10 NA 9 20 25 10 1521 NA10 NA 10578566478753 361 150 262 170 > dim(Species.all) [1] 18628 I used apply function like below. I used this same function for some other data, there it worked. But here its not working (giving error message). > Range.j=apply(Species.all,1,max,na.rm = TRUE)-apply(Species.all,1,min,na.rm = TRUE) Error in apply(Species.all, 1, max, na.rm = TRUE) - apply(Species.all, : non-numeric argument to binary operator When i tried to check, you can see from the steps it is giving totally wrong results. > apply(Species.all[1:10,],1,max) 1 2 3 4 5 6 7 8 9 10 "7286" "3258" "1024" NA NA NA NA NA NA " 753" > apply(Species.all[1:10,],1,min) 1234567 89 10 " 47175" " 29887" " 18538" NA NA NA NA NA NA " 262" Main problem is, this code is working for some cases, but not for all. Does any body have an idea, why it is so? Or can anyone show me some other way to do the same. Thanks in advance, With best regard, Suparna [[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 build phylogenetic tree by R program from distance any distance matrix
Hello R users, Can any one please help me to find a way to build phylogenetic tree by R program from any distance matrix. Suppose I have a data like : MATRIX [1] '1'0.0 [2] '2'0.071 0.0 [3] '3'0.036 0.286 0.0 [4] '4'0.429 0.75 0.714 0.0 [5] '5' 0.679 0.179 0.214 0.536 0.0 [6] '6' 0.893 0.929 0.964 0.464 0.357 0.0 [7] '7' 0.643 0.571 0.5 0.607 0.821 0.786 0.0 [8] '8' 0.857 0.393 0.107 0.321 0.25 0.0 0.143 0.0 Or as a vector I have the lower triangle like: > dist.mat [1] 0.071 0.036 0.286 0.429 0.750 0.714 0.679 0.179 0.214 0.536 0.893 0.929 0.964 0.464 0.357 0.643 0.571 0.500 0.607 0.821 0.786 0.857 0.393 0.107 0.321 0.250 0.000 0.143 It will be really helpful if anyone can help me to get a tree (between these 8 species) from this vector values. The matrix above I created by hand to use as a nexus distance matrix data for other methods. So it is better if I can use this distance matrix vector (dist.mat) directly. I couldn't find any package for phylogenetic tree from distance any distance matrix in R. Thank you very much. With best regard, Suparna [[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] R: Best way to plot a Matrix of all possible pair combinations
Hallo R Users, Please help I have some distance matrix data like > M[1:10,] [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0.875 0.500 0.500 0.375 0.625 0. [2,] 0.8928571 1.000 0.000 0.8928571 0.1071429 0. [3,] 0.8928571 1.000 0.000 0.8928571 0.1071429 0. [4,] 0.8928571 1.000 0.000 0.8928571 0.1071429 0. [5,] 1.000 0.1304348 0.8695652 0.1304348 0.8695652 0. [6,] 1.000 0.1304348 0.8695652 0.1304348 0.8695652 0. [7,] 1.000 0.1304348 0.8695652 0.1304348 0.8695652 0. [8,] 0.9497743 0.7605977 0.2394023 0.7103720 0.2896280 0. [9,] 0.0754717 0.7169811 0.000 0.3584906 0.9245283 0.28301887 [10,] 0.3870968 0.9354839 0.000 0.4516129 0.6129032 0.06451613 where all the columns (1 to 6) are representing all possible pair-wise combination from four datasets, like cmbn [,1] [,2] [,3] [,4] [,5] [,6] [1,]111223 [2,]234344 and all the rows represent different species so; > M[1,1] [1] 0.875## is the distance value for species 1 for combination data pair 1& 2. Can any body please suggest me what will be the best way to represent these results in plot? Thanks a lot in advance, With best regard, Suparna [[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] Best way to plot a Matrix of all possible pair combinations
Hallo R Users, I have some distance matrix data like > M[1:10,] [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0.875 0.500 0.500 0.375 0.625 0. [2,] 0.8928571 1.000 0.000 0.8928571 0.1071429 0. [3,] 0.8928571 1.000 0.000 0.8928571 0.1071429 0. [4,] 0.8928571 1.000 0.000 0.8928571 0.1071429 0. [5,] 1.000 0.1304348 0.8695652 0.1304348 0.8695652 0. [6,] 1.000 0.1304348 0.8695652 0.1304348 0.8695652 0. [7,] 1.000 0.1304348 0.8695652 0.1304348 0.8695652 0. [8,] 0.9497743 0.7605977 0.2394023 0.7103720 0.2896280 0. [9,] 0.0754717 0.7169811 0.000 0.3584906 0.9245283 0.28301887 [10,] 0.3870968 0.9354839 0.000 0.4516129 0.6129032 0.06451613 where all the columns (1 to 6) are representing all possible pair-wise combination from four datasets, like cmbn [,1] [,2] [,3] [,4] [,5] [,6] [1,]111223 [2,]234344 and all the rows represent different species so; > M[1,1] [1] 0.875## is the distance value for species 1 for combination data pair 1& 2. Can any body please suggest me what will be the best way to represent these results in plot? Thanks a lot in advance, With best regard, Suparna --- [[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] Need some help in R : value more than equals to a row.
Hallo, I was trying some code, but couldn't make one step of the code properly. Can anybody please help me? I have one matrix like this > values [,1] [,2] [,3] [,4] [,5] [1,] 0.778 0.3611 0. 0.139 0.000 [2,] 1.000 0. 0.53846154 0.000 0.5384615 [3,] 0.520 0.4800 0.6400 0.000 0.880 [4,] 0.8928571 1. 0. 0.8928571 0.1071429 And I want to get some matrix like: > values.new [,1] [,2] [,3] [,4] [,5] [1,] 0.2 0.4 0.6 0.8 1.0 [2,] 0.2 1.0 0.6 1.0 0.6 [3,] 0.6 0.8 0.4 1.0 0.2 [4,] 0.6 0.2 1.0 0.6 0.8 This table should be computed by taking proportion of values in the row that are larger or equals to the value being considered with the total no of objects in the row. for example > values[1,2] [1] 0.361 and > values[1,] [1] 0.778 0.361 0.222 0.139 0.000 0.861 So there are two numbers more than equals to values[1,2] So > values.new[1,2]= 2/length(values[1,]) With best regard, Suparna [[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] Need some help in R : value more than equals to a row.
Hallo, I was trying some code, but couldn't make one step of the code properly. Can anybody please help me? I have one matrix like this > values [,1] [,2] [,3] [,4] [,5] [1,] 0.778 0.3611 0. 0.139 0.000 [2,] 1.000 0. 0.53846154 0.000 0.5384615 [3,] 0.520 0.4800 0.6400 0.000 0.880 [4,] 0.8928571 1. 0. 0.8928571 0.1071429 And I want to get some matrix like: > values.new [,1] [,2] [,3] [,4] [,5] [1,] 0.2 0.4 0.6 0.8 1.0 [2,] 0.2 1.0 0.6 1.0 0.6 [3,] 0.6 0.8 0.4 1.0 0.2 [4,] 0.6 0.2 1.0 0.6 0.8 This table should be computed by taking proportion of values in the row that are larger or equals to the value being considered with the total no of objects in the row. for example > values[1,2] [1] 0.361 and > values[1,] [1] 0.778 0.361 0.222 0.139 0.000 0.861 So there are two numbers more than equals to values[1,2] So > values.new[1,2]= 2/length(values[1,]) With best regard, Suparna -------- Ms Suparna Mitra Eberhard-Karls-Universität Tübingen Wilhelm-Schickard-Institut Algorithmen der Bioinformatik Sand 14, 72076 Tuebingen Germany Tel. ++49-7071-29 70453 (0) Fax ++49-7071-29 5148 (0) Phone: ++49-176-20361469 (M) ++49-7071-1477169 (R) Alternative e-mail: mi...@informatik.uni-tuebingen.de [[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.