Re: [R] caculate correlation
Hi Elham, It looks to me as though you are looking for matches in the name field and then asking for all columns except the first (-1). If you only have two columns in "coding.rpkm", and "name" is the first column, you will get whatever is in the second column that has a match in the "name" column. I suspect that whatever you are doing to whatever is in the data frames is just returning names, and without knowing what the data frames look like, nobody can tell you what is going wrong. Jim On Tue, Jan 31, 2017 at 10:31 PM, Elham -wrote: > thank you for replay dear Jim, > actually I`m new in R and I asked the person that teach correlation to > me,but I have problem in it. > please guide me, I can not understand why notwithstanding I transpose data, > I do not have number in coding.rpkm[grep("23.C",coding.rpkm$name),-1] and > there is gene name instead of number > > > On Tuesday, January 31, 2017 12:20 PM, Jim Lemon > wrote: > > > Hi Elham, > > On Tue, Jan 31, 2017 at 7:28 PM, Elham - wrote: >> Hi Dear Jim, >> >> I did it, both return a vector of name of the genes with different >> length,as >> I said before I have list of coding and noncoding so the length are not >> same. >> >> where is number?! >> > Not in the values you are extracting from the data frame. As you are > aware, you can only perform the "cor" operation on numbers. As the > value returned refers to the correlation of _pairs_ of values, the > vectors of numbers should be the same length and there should be some > meaningful relationship between those pairs. Are you just trying to > correlate any old numbers because they are numbers? > >> and at the end of print there is this error : >> >> <0 rows> (or 0-length row.names) >> > This is probably not an error, just R telling you that something that > was requested didn't have anything in it. Maybe one day we will find > out what is in: > > coding.rpkm > ncoding.rpkm > > and we can provide more informed advice. > > > Jim > > __ 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] caculate correlation
Hi Dear Jim, I did it, both return a vector of name of the genes with different length,as I said before I have list of coding and noncoding so the length are not same. where is number?! and at the end of print there is this error : <0 rows> (or 0-length row.names) On Tuesday, January 31, 2017 3:07 AM, Jim Lemonwrote: Hi Elham, What I meant is to simply copy these two expressions into the R command line: coding.rpkm[grep("23.C",coding.rpkm$name),-1] ncoding.rpkm[grep("23.C",ncoding.rpkm$name),-1] and see what comes out. If both return a vector of numbers of the same length with no NA values, my guess was wrong. If there are NA values, try adding the argument use=pairwise.complete.obs to the "cor" statement. Jim On Tue, Jan 31, 2017 at 9:17 AM, Elham - wrote: > this script automatically recognizes what is control among cod and lnc. Note > that this script contains a piece of text that is "grep(".C",cod$name)". > This text select - among all column names - those that contain ".C". in my > files, I named C1, C2, C3, etc all columns that correspond to controls. In > the same manner, I get controls among the lnc, with the text: > "grep(".C",lnc$name)" > > I`m so sorry,maybe I do not understand you again. > > > On Tuesday, January 31, 2017 1:27 AM, Jim Lemon > wrote: > > > Hi Elham, > This is about the same as your first message. What I meant was, what > do these two expressions return? Is whatever is returned suitable > input for the "cor" function? > > coding.rpkm[grep("23.C",coding.rpkm$name),-1] > > ncoding.rpkm[grep("23.C",ncoding.rpkm$name),-1] > > Jim > > > On Tue, Jan 31, 2017 at 8:45 AM, Elham - wrote: >> I have 9 experiments control/treatment that I analysed coding and >> lncoding, >> after that I normalize expression value.as you know we have different >> known >> number of coding and non -coding genes,so for calculating correlation >> first >> I transposed data ,(rows become columns)so row is control and >> columns are gene names.(so I have 2 matrix with same row and different >> column).This information is enough? >> >> >> >> >> On Tuesday, January 31, 2017 1:06 AM, Jim Lemon >> wrote: >> >> >> Hi Elham, >> Without knowing much about what coding.rpkm and ncoding.rkpm look >> like, it is difficult to say. Have you tried to subset these matrices >> as you do in the "cor" function and see what is returned? >> >> Jim >> >> On Tue, Jan 31, 2017 at 6:40 AM, Elham - via R-help >> wrote: >>> for calculating correlation between coding and noncoding,first I >>> transposed data ,(rows become columns) so row is control and >>> columns are gene names.(so I have 2 matrix with same row and different >>> column),I use these function for calculating correlation but all of >>> spearman >>> correlation are NA,why? >>> >>> >>> >>> >>> control.corr=cor(coding.rpkm[grep("23.C",coding.rpkm$name),-1],ncoding.rpkm[grep("23.C",ncoding.rpkm$name),-1],method= >>> "spearman") >>> >>> >>> >>> >>> >>> >>> >>> tumor.corr=cor(coding.rpkm [grep("27.T", coding.rpkm $name),-1], >>> ncoding.rpkm [grep("27.T", ncoding.rpkm $name),-1],method = "spearman") >>> >>> [[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. >> >> > > [[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] caculate correlation
Hi Elham, On Tue, Jan 31, 2017 at 7:28 PM, Elham -wrote: > Hi Dear Jim, > > I did it, both return a vector of name of the genes with different length,as > I said before I have list of coding and noncoding so the length are not > same. > > where is number?! > Not in the values you are extracting from the data frame. As you are aware, you can only perform the "cor" operation on numbers. As the value returned refers to the correlation of _pairs_ of values, the vectors of numbers should be the same length and there should be some meaningful relationship between those pairs. Are you just trying to correlate any old numbers because they are numbers? > and at the end of print there is this error : > > <0 rows> (or 0-length row.names) > This is probably not an error, just R telling you that something that was requested didn't have anything in it. Maybe one day we will find out what is in: coding.rpkm ncoding.rpkm and we can provide more informed advice. Jim __ 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] caculate correlation
Hi Elham, What I meant is to simply copy these two expressions into the R command line: coding.rpkm[grep("23.C",coding.rpkm$name),-1] ncoding.rpkm[grep("23.C",ncoding.rpkm$name),-1] and see what comes out. If both return a vector of numbers of the same length with no NA values, my guess was wrong. If there are NA values, try adding the argument use=pairwise.complete.obs to the "cor" statement. Jim On Tue, Jan 31, 2017 at 9:17 AM, Elham -wrote: > this script automatically recognizes what is control among cod and lnc. Note > that this script contains a piece of text that is "grep(".C",cod$name)". > This text select - among all column names - those that contain ".C". in my > files, I named C1, C2, C3, etc all columns that correspond to controls. In > the same manner, I get controls among the lnc, with the text: > "grep(".C",lnc$name)" > > I`m so sorry,maybe I do not understand you again. > > > On Tuesday, January 31, 2017 1:27 AM, Jim Lemon > wrote: > > > Hi Elham, > This is about the same as your first message. What I meant was, what > do these two expressions return? Is whatever is returned suitable > input for the "cor" function? > > coding.rpkm[grep("23.C",coding.rpkm$name),-1] > > ncoding.rpkm[grep("23.C",ncoding.rpkm$name),-1] > > Jim > > > On Tue, Jan 31, 2017 at 8:45 AM, Elham - wrote: >> I have 9 experiments control/treatment that I analysed coding and >> lncoding, >> after that I normalize expression value.as you know we have different >> known >> number of coding and non -coding genes,so for calculating correlation >> first >> I transposed data ,(rows become columns)so row is control and >> columns are gene names.(so I have 2 matrix with same row and different >> column).This information is enough? >> >> >> >> >> On Tuesday, January 31, 2017 1:06 AM, Jim Lemon >> wrote: >> >> >> Hi Elham, >> Without knowing much about what coding.rpkm and ncoding.rkpm look >> like, it is difficult to say. Have you tried to subset these matrices >> as you do in the "cor" function and see what is returned? >> >> Jim >> >> On Tue, Jan 31, 2017 at 6:40 AM, Elham - via R-help >> wrote: >>> for calculating correlation between coding and noncoding,first I >>> transposed data ,(rows become columns) so row is control and >>> columns are gene names.(so I have 2 matrix with same row and different >>> column),I use these function for calculating correlation but all of >>> spearman >>> correlation are NA,why? >>> >>> >>> >>> >>> control.corr=cor(coding.rpkm[grep("23.C",coding.rpkm$name),-1],ncoding.rpkm[grep("23.C",ncoding.rpkm$name),-1],method= >>> "spearman") >>> >>> >>> >>> >>> >>> >>> >>> tumor.corr=cor(coding.rpkm [grep("27.T", coding.rpkm $name),-1], >>> ncoding.rpkm [grep("27.T", ncoding.rpkm $name),-1],method = "spearman") >>> >>>[[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-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] caculate correlation
this script automatically recognizes what is control among cod and lnc. Note that this script contains a piece of text that is "grep(".C",cod$name)". This text select - among all column names - those that contain ".C". in my files, I named C1, C2, C3, etc all columns that correspond to controls. In the same manner, I get controls among the lnc, with the text: "grep(".C",lnc$name)" I`m so sorry,maybe I do not understand you again. On Tuesday, January 31, 2017 1:27 AM, Jim Lemonwrote: Hi Elham, This is about the same as your first message. What I meant was, what do these two expressions return? Is whatever is returned suitable input for the "cor" function? coding.rpkm[grep("23.C",coding.rpkm$name),-1] ncoding.rpkm[grep("23.C",ncoding.rpkm$name),-1] Jim On Tue, Jan 31, 2017 at 8:45 AM, Elham - wrote: > I have 9 experiments control/treatment that I analysed coding and lncoding, > after that I normalize expression value.as you know we have different known > number of coding and non -coding genes,so for calculating correlation first > I transposed data ,(rows become columns)so row is control and > columns are gene names.(so I have 2 matrix with same row and different > column).This information is enough? > > > > > On Tuesday, January 31, 2017 1:06 AM, Jim Lemon > wrote: > > > Hi Elham, > Without knowing much about what coding.rpkm and ncoding.rkpm look > like, it is difficult to say. Have you tried to subset these matrices > as you do in the "cor" function and see what is returned? > > Jim > > On Tue, Jan 31, 2017 at 6:40 AM, Elham - via R-help > wrote: >> for calculating correlation between coding and noncoding,first I >> transposed data ,(rows become columns) so row is control and >> columns are gene names.(so I have 2 matrix with same row and different >> column),I use these function for calculating correlation but all of spearman >> correlation are NA,why? >> >> >> >> control.corr=cor(coding.rpkm[grep("23.C",coding.rpkm$name),-1],ncoding.rpkm[grep("23.C",ncoding.rpkm$name),-1],method= >> "spearman") >> >> >> >> >> >> >> >> tumor.corr=cor(coding.rpkm [grep("27.T", coding.rpkm $name),-1], >> ncoding.rpkm [grep("27.T", ncoding.rpkm $name),-1],method = "spearman") >> >> [[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. > > [[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] caculate correlation
Hi Elham, This is about the same as your first message. What I meant was, what do these two expressions return? Is whatever is returned suitable input for the "cor" function? coding.rpkm[grep("23.C",coding.rpkm$name),-1] ncoding.rpkm[grep("23.C",ncoding.rpkm$name),-1] Jim On Tue, Jan 31, 2017 at 8:45 AM, Elham -wrote: > I have 9 experiments control/treatment that I analysed coding and lncoding, > after that I normalize expression value.as you know we have different known > number of coding and non -coding genes,so for calculating correlation first > I transposed data ,(rows become columns)so row is control and > columns are gene names.(so I have 2 matrix with same row and different > column).This information is enough? > > > > > On Tuesday, January 31, 2017 1:06 AM, Jim Lemon > wrote: > > > Hi Elham, > Without knowing much about what coding.rpkm and ncoding.rkpm look > like, it is difficult to say. Have you tried to subset these matrices > as you do in the "cor" function and see what is returned? > > Jim > > On Tue, Jan 31, 2017 at 6:40 AM, Elham - via R-help > wrote: >> for calculating correlation between coding and noncoding,first I >> transposed data ,(rows become columns) so row is control and >> columns are gene names.(so I have 2 matrix with same row and different >> column),I use these function for calculating correlation but all of spearman >> correlation are NA,why? >> >> >> >> control.corr=cor(coding.rpkm[grep("23.C",coding.rpkm$name),-1],ncoding.rpkm[grep("23.C",ncoding.rpkm$name),-1],method= >> "spearman") >> >> >> >> >> >> >> >> tumor.corr=cor(coding.rpkm [grep("27.T", coding.rpkm $name),-1], >> ncoding.rpkm [grep("27.T", ncoding.rpkm $name),-1],method = "spearman") >> >>[[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-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] caculate correlation
I have 9 experiments control/treatment that I analysed coding and lncoding, after that I normalize expression value.as you know we have different known number of coding and non -coding genes,so for calculating correlation first I transposed data ,(rows become columns)so row is control and columns are gene names.(so I have 2 matrix with same row and different column).This information is enough? On Tuesday, January 31, 2017 1:06 AM, Jim Lemonwrote: Hi Elham, Without knowing much about what coding.rpkm and ncoding.rkpm look like, it is difficult to say. Have you tried to subset these matrices as you do in the "cor" function and see what is returned? Jim On Tue, Jan 31, 2017 at 6:40 AM, Elham - via R-help wrote: > for calculating correlation between coding and noncoding,first I transposed > data ,(rows become columns) so row is control and columns are gene > names.(so I have 2 matrix with same row and different column),I use these > function for calculating correlation but all of spearman correlation are > NA,why? > > > control.corr=cor(coding.rpkm[grep("23.C",coding.rpkm$name),-1],ncoding.rpkm[grep("23.C",ncoding.rpkm$name),-1],method= > "spearman") > > > > > > > > tumor.corr=cor(coding.rpkm [grep("27.T", coding.rpkm $name),-1], ncoding.rpkm > [grep("27.T", ncoding.rpkm $name),-1],method = "spearman") > > [[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. [[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] caculate correlation
Hi Elham, Without knowing much about what coding.rpkm and ncoding.rkpm look like, it is difficult to say. Have you tried to subset these matrices as you do in the "cor" function and see what is returned? Jim On Tue, Jan 31, 2017 at 6:40 AM, Elham - via R-helpwrote: > for calculating correlation between coding and noncoding,first I transposed > data ,(rows become columns) so row is control and columns are gene > names.(so I have 2 matrix with same row and different column),I use these > function for calculating correlation but all of spearman correlation are > NA,why? > > > control.corr=cor(coding.rpkm[grep("23.C",coding.rpkm$name),-1],ncoding.rpkm[grep("23.C",ncoding.rpkm$name),-1],method= > "spearman") > > > > > > > > tumor.corr=cor(coding.rpkm [grep("27.T", coding.rpkm $name),-1], ncoding.rpkm > [grep("27.T", ncoding.rpkm $name),-1],method = "spearman") > > [[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-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] caculate correlation
for calculating correlation between coding and noncoding,first I transposed data ,(rows become columns) so row is control and columns are gene names.(so I have 2 matrix with same row and different column),I use these function for calculating correlation but all of spearman correlation are NA,why? control.corr=cor(coding.rpkm[grep("23.C",coding.rpkm$name),-1],ncoding.rpkm[grep("23.C",ncoding.rpkm$name),-1],method= "spearman") tumor.corr=cor(coding.rpkm [grep("27.T", coding.rpkm $name),-1], ncoding.rpkm [grep("27.T", ncoding.rpkm $name),-1],method = "spearman") [[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.