Re: [R] How to retrieve data from a matrix

2012-11-19 Thread ginger
Thank you very much, It works!



--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-retrieve-data-from-a-matrix-tp4649721p4650036.html
Sent from the R help mailing list archive at Nabble.com.

__
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 retrieve data from a matrix

2012-11-16 Thread ginger
I have a data set (data.txt) containing information on affection status
(1=affected; 0=not affected) for some subjects identified by an ID. Then I
have a sort of correlation matrix of the same subjects (matrix.txt). For
each affected subject in the data set I have to retrieve the IDs of
unaffected subjects from the matrix (if the condition “affected-unaffected
correlation0.0165” is satisfied) and such IDs should  be placed in new
columns of the data set on the affected subject corresponding row.
Does anybody can help me?
data.txt http://r.789695.n4.nabble.com/file/n4649721/data.txt   matrix.txt
http://r.789695.n4.nabble.com/file/n4649721/matrix.txt  



--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-retrieve-data-from-a-matrix-tp4649721.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Script for searching in a kinship matrix

2012-11-10 Thread ginger
Hi everybody!
I suceeded in extracting the sub-matrix containing just the relevant
subjects of this example data (indeed I could retrieve 190 of the 220
subjects of the data example, so that the relative kinship matrix is a
190X190). For the subjects non present in the kinship matrix case-control
kinship coefficient is to be supposed as 0 (zero) - no relatedness.
I attach this example kinship matrix. KinExample.txt
http://r.789695.n4.nabble.com/file/n4649178/KinExample.txt  



--
View this message in context: 
http://r.789695.n4.nabble.com/Script-for-searching-in-a-kinship-matrix-tp4649089p4649178.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Script for searching in a kinship matrix

2012-11-09 Thread ginger
Hi everybody!
In a case-control study I have already sampled cases stratifying for sex
(0,1) and age (62y, =62y). I need to sample a group of controls with the
same characteristics (which I can easily do) plus one more: the level of
relatedness. Therefore controls should be matched to cases for sex (2
strata), age(2 strata) and, relatedness (less than a certain level). In
particular I need that controls are as least as possible related to cases,
for example each control should have a kinship coefficient less than 0.0156
(i.e. 1/64 as for second cousins) with its matched case. In the attached
example data set (Example.txt) there are the sampled cases (20 cases: 5
subjects for each strata) and 200 possible controls I have already sampled
stratifying for age and sex (50 subjects per strata).
What I do not know is how to solve the relatedness problem. I have already
computed the kinship coefficients matrix of the extended pedigree to whom
the cases and controls in the example data belong. I do not provide it now
because is a 4762 rows per 4762 columns matrix, and I do not know how to
extract the sub-matrix containing just the relevant 220 subjects of this
example data.
As an example, such a kinship matrix for 5 subjects (ID: 51, 59, 119, 156
and 178) is like:
51  59  119 156 178
51  0.500   0.000   0.000   0.000   0.000
59  0.000   0.500   0.250   0.000   0.250
119 0.000   0.250   0.500   0.000   0.250
156 0.000   0.000   0.000   0.500   0.000
178 0.000   0.250   0.250   0.000   0.500
In conclusion I think I need a script that looks down such kinship matrix
searching for controls satisfying the relatedness condition and that adds to
my data set (Example.txt) as many columns as the maximum number of controls
satisfying the relatedness condition for their matched cases. In particular
in correspondence of each case (rows for which disease=1) the new columns
should return the ID of the match control satisfying the
condition:case-control kinship 0.0156 ; otherwise a missing value (such as
NA). Such new columns will contain a value (ID code) only for cases and a
missing value for controls.
Does anybody can help me?
Ginger
Example.txt http://r.789695.n4.nabble.com/file/n4649089/Example.txt  



--
View this message in context: 
http://r.789695.n4.nabble.com/Script-for-searching-in-a-kinship-matrix-tp4649089.html
Sent from the R help mailing list archive at Nabble.com.

__
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] parsing text files

2012-03-08 Thread ginger
Hello, I have a .txt file with many clinical exams reports (two examples of
which are attached to the message).
I have to create a data frame with as many rows as the number of clinical
exams reports in the text file and 24 columns:
the first (to be labelled as ID) with a number (representing an
identification code) which is the number in the 13th line of the clinical
report following the string Acc.ne n. 
the second (to be labelled as DATE) with a date (indicating date of blood
sampling), which is the date, again in the 13th line, following the
identification code
the following 22 columns (to be labelled with the name of parameters at
lines from 20 to 41, as GLICEMIA ... COLESTEROLO LDL)

I did search in the mailing list and tried to begin something like:

#read the text file
reports - readLines(ClinicalReports.txt)
#processing the file starting at each Acc.ne n. 
serologic - lapply(which(grepl(^Acc.ne n., reports)), function(.line
)

but I'm a biostatistician whith almost no expertise in programming and I
really need your hepl! Please!!!
http://r.789695.n4.nabble.com/file/n4456355/ClinicalReports.txt
ClinicalReports.txt 

--
View this message in context: 
http://r.789695.n4.nabble.com/parsing-text-files-tp4456355p4456355.html
Sent from the R help mailing list archive at Nabble.com.

__
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] parsing text files

2012-03-08 Thread ginger
Ooops,
I forgot to specify that for each raw, containing records of the clinical
reports , the values  of the 22 parameter measurement have to be reported.
For example, first raw, first 5 columns:
ID  DATE  GLICEMIA   AZOTEMIA 
CREATININEMIASODIEMIA  ......  ...
185  05/12/2011115  33.6  0.99  
  
136 ......  ...

--
View this message in context: 
http://r.789695.n4.nabble.com/parsing-text-files-tp4456355p4456389.html
Sent from the R help mailing list archive at Nabble.com.

__
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.