Re: [R] Measure the frequencies of pairs in a matrix

2015-10-08 Thread Hermann Norpois
> for (i in 1:nrow(mat)) { > > # Sort the elements of a row by size. > > x <- sort(mat[i,]) > > # Increment the corresponding element of the frequency matrix > > freq[x[1], x[2]] <- freq[x[1], x[2]] + 1 > > } > > > > freq > > >

Re: [R] Measure the frequencies of pairs in a matrix

2015-10-07 Thread Hermann Norpois
7;t understand the second part about values "that do not appear in > the matrix". Do you mean you want to assess all combinations? If that's the > case I would think about a hash table or other indexed data structure, > rather than iterating through a matrix. > > >

Re: [R] cut - strange NA as output

2015-10-06 Thread Hermann Norpois
Thanks this was very helpful. @Olivier Crouzet: Yes, round (x) would do the job but it was a principal confusion ... 2015-10-06 21:57 GMT+02:00 Marc Schwartz : > > > On Oct 6, 2015, at 2:20 PM, Hermann Norpois wrote: > > > > Hello, > > > > why do I get NA for t

[R] Measure the frequencies of pairs in a matrix

2015-10-06 Thread Hermann Norpois
Hello, I have a matrix mat (see dput(mat)) > mat [,1] [,2] [1,]56 [2,]65 [3,]54 [4,]55 I want the frequencies of the pairs in a new matrix, whereas the combination 5 and 6 is the same as 6 and 5 (see the first two rows of mat). In other words: Wha

[R] cut - strange NA as output

2015-10-06 Thread Hermann Norpois
Hello, why do I get NA for the following: cut (x, seq (0, max(x), by=1), label=FALSE) [1] 1322 1175 1155 1149 1295 1173 1289 1197 NA 1129 dput (x) c(1321.55376901374, 1174.35657200935, 1154.02042504008, 1148.60981925942, 1294.6166388941, 1172.45806806869, 1288.31933914639, 1196.26080041462, 1

[R] lines - defining the range that is plotted

2015-09-24 Thread Hermann Norpois
Hello, I am looking for a possibility to define something like ylim for lines. I thought, there might be a possibility to define the range of lines by means of par ("usr") but I did not find the correct syntax. In my toy example I would like to stop the red line at y=0.3. Thanks Hermann toy examp

[R] mtext in the top left of margin

2015-09-16 Thread Hermann Norpois
Hello, for a multiple figures plot I am looking for the syntax to put text in the top left of the margin (of the plot). I want my testfunction plot.figure to place mtext in the top left of the red margin (created by box("figure", col="red")). Can anybody help? Thanks Hermann plot.figure <- func

Re: [R] scan - open text file as list

2015-04-15 Thread Hermann Norpois
; > > [[2]] > [1] "z" "u" "i" "h" "hh" > > [[3]] > [1] "h" "bh" "kk" > > > Bill Dunlap > TIBCO Software > wdunlap tibco.com > > On Tue, Apr 14, 2015 at 2:34 PM, Hermann Norpois >

[R] scan - open text file as list

2015-04-14 Thread Hermann Norpois
Hello, I try to open a text file test.txt with the content * a b d * z u i h hh * h bh kk so that I get a list with each line as a vector with the letters as elements of the the vector. My approach ... test <- scan ("test.txt", what="character", sep="\n") Read 3 items > test.list <- lapply (tes

[R] completely different results for shapiro.test and ks.test

2014-03-27 Thread Hermann Norpois
Hello, My main question is wheter my data is distributed normally. As the shapiro.test doesnt work for large data sets I prefer the ks.test. But I have some problems to understand the completely different p-values: > ks.test (test, pnorm, mean (test), sd (test)) One-sample Kolmogorov-Smirno

[R] as.Date converts to NA

2014-03-09 Thread Hermann Norpois
Hello, I have some problems with as.Date. strDates <- c ("01/05/1965", "08/16/1975") dates <- as.Date (strDates, "%m/%d%/%Y") dates [1] NA NA # I expected my dates. What was going wrong? Thanks Hermann [[alternative HTML version deleted]] __ R

[R] use grep in lists and vectors

2014-01-12 Thread Hermann Norpois
Hello, I want to detect Ab not Abc. For a normal vector test [1] "A" "Ab" "GG" "GA" "H" "Abc" "Gz" "HU" > grep ("^Ab$", test) [1] 2 works well. For test.list [[1]] [1] "A" "Ab" "GG" "GA" [[2]] [1] "H" "Abc" "Gz" "HU" grep ("^Ab$", test.list) integer(0) doest not work. Why? How

[R] Find backward duplicates in a data frame

2013-11-15 Thread Hermann Norpois
Hello, I am looking for a method to eliminate rows dupblicates in a backwards manner, for instance: I want to keep A B but not B A (see my data.frame test). Thanks Hermann > test a u 1 A B 2 A C 3 B A 4 B F 5 C A 6 D W > dput (test) structure(list(a = structure(c(1L, 1L, 2L, 2L, 3L, 4L), .Label

Re: [R] From list to dataframe

2013-11-14 Thread Hermann Norpois
t; > > On Thursday, November 14, 2013 8:27 AM, Hermann Norpois < > hnorp...@gmail.com> wrote: > Hello, > > having a list like testlist I would like to transform it in dataframe. How > does it work? > > Thanks > Hermann > > > testlist > [[1]] > B

[R] From list to dataframe

2013-11-14 Thread Hermann Norpois
Hello, having a list like testlist I would like to transform it in dataframe. How does it work? Thanks Hermann > testlist [[1]] BP_A SNP_A BP_B SNP_B R2 2 27001689 rs4822747 27002392 rs4820690 0.695642 3 27001689 rs4822747 27004298 rs5761627 0.695642 4 27001689 rs4822747

Re: [R] union of list objects if objects intersect

2013-11-10 Thread Hermann Norpois
chain3 <- chain1 huz[[i]] <- sort (chain3) next } } } huz <- unique (huz) return (huz) } 2013/11/9 Hermann Norpois > Hello, > > I

Re: [R] union of list objects if objects intersect

2013-11-10 Thread Hermann Norpois
==0 but intersect(ja[[i]],ja[[i+2]]) is nonempty? Your > example isn't -- you did not specify what the return should be on your > list. > > Note also that your example test is wrong: the length of the > intersection must =0 not the intersection. > > -- Bert > > &

[R] union of list objects if objects intersect

2013-11-09 Thread Hermann Norpois
Hello, I have a list called ja and I wish to unify list objects if there is some overlap. For instance something like if (length (intersect (ja[[1]], ja[[2]]) !=0) { union (ja[[1]], ja[[2]] } but of course it should work cumulatively (for larger data sets). Could you please give me a hint. Tha

[R] making chains from pairs

2013-11-08 Thread Hermann Norpois
Hello, having a data frame like test with pairs of characters I would like to create chains. For instance from the pairs A/B and B/I you get the vector A B I. It is like jumping from one pair to the next related pair. So for my example test you should get: A B F G H I C F I K D L M N O P > test

Re: [R] SNPRelate: Plink conversion

2013-11-08 Thread Hermann Norpois
You might try to import your data in GenABEL, use as.numeric (gtdata (data)) to get a matrix that delivers you 0,1 or 2 for each snp and id (observation) and then try prcomp. Also check this http://gettinggeneticsdone.blogspot.de/2011/10/new-dimension-to-principal-components_27.html http://www.hs

Re: [R] plot - how to vary the distances of the x axis?

2013-10-18 Thread Hermann Norpois
Thanks. This was helpful. Hermann 2013/10/17 Bretschneider (R) > > On 17 Oct 2013, at 13:44 , Hermann Norpois wrote: > > Hello, > > > my dots of 0 and 2 are quite close to the marging. So I would like to move > the 0 and the 2 both towards the 1. I wish to be my dots

[R] plot - how to vary the distances of the x axis?

2013-10-17 Thread Hermann Norpois
Hello, my dots of 0 and 2 are quite close to the marging. So I would like to move the 0 and the 2 both towards the 1. I wish to be my dots more centered. And: I dont need so much space between 0,1 and 2. How does it work? I tried: plot (data, axes=FALSE, main=i, ylab= expression (z^2))

Re: [R] plot: want only dots

2013-10-16 Thread Hermann Norpois
gt; > It sounds like you might want: > > with(mydata, plot(as.numeric(as.character(Genotype)), z)) > > but if Genotype is best represented as a factor, that may not be the > most informative type of plot. > > Sarah > > On Tue, Oct 15, 2013 at 10:23 AM, Hermann Norpois >

[R] plot: want only dots

2013-10-15 Thread Hermann Norpois
Hello, I would like to plot some values referring to the genotype (which is 0,1 and 2). My data is organised like this: head (df) Genotype z 10 0.07029379 20 2.15739115 30 0.51395897 40 0.48733029 50 0.15584074 60 0.27755294 I tried: >

Re: [R] prcomp - surprising structure

2013-10-03 Thread Hermann Norpois
e on TV".) > > To investigate further, you could go looking at the individual scores and > see who is having extreme values on component 2-4 and then go back and see > if there is something peculiar about their SNPs in the "strange" region. > > Of course, you might h

[R] prcomp - surprising structure

2013-10-03 Thread Hermann Norpois
Hello, I did a pca with over 20 snps for 340 observations (ids). If I plot the eigenvectors (called rotation in prcomp) 2,3 and 4 (e.g. plot (rotation[,2]) I see a strange "column" in my data (see attachment). I suggest it is an artefact (but of what?). Suggestion: I used prcomp this way: prc

[R] leveneTest - output

2013-10-01 Thread Hermann Norpois
Hello, I have a question concerning the output of leveneTest. I don't understand the "7" in my output Levene's Test for Homogeneity of Variance (center = median) Df F value Pr(>F) group 2 0.0173 0.9829 7# Where does this number come from? Thanks. Hermann > res group.I

[R] plot - scaling axis

2013-09-24 Thread Hermann Norpois
Hello, i attached an example with two plotted vectors, respectively. And you might see that the y and x axis are not the same scale (e.g. the third and the last plot). I would prefer them to be the same scale. A toy example: a <- c (1,2,3,4,5,6,9,20) > b <- c (0.2,0.4,0.6,1,0.5,1,1,0.1) > plot

[R] cov and huge matrix

2013-09-17 Thread Hermann Norpois
Hello, I tried to compute the covariance (between the columns) of a matrix with >20. This failed ... Error: cannot allocate vector of size 691.2 GB Ok, this is rather huge. But ... On the other hand ... Is there an alternative to cov? Maybe one could combine combn with cov - so it is rather

[R] princomp needs more obsverations than variables?

2013-09-12 Thread Hermann Norpois
Hello, I would like to do a pca with princomp. I have a dataset with different observations for each row and for different variables for each column (test.z). If I understood it correctly this is the way the data should be structured for princomp. But it does not work. But if I transpose the mat

Re: [R] glm - change offset to avoid NA?

2013-07-16 Thread Hermann Norpois
t you want is > > ?try ##or > ?tryCatch > > ## The second is more flexible but slightly more complicated. > > to trap the error and perhaps refit the model without interaction? > > Cheers, > Bert > > On Mon, Jul 15, 2013 at 10:45 AM, Hermann Norpois > w

[R] glm - change offset to avoid NA?

2013-07-15 Thread Hermann Norpois
Hello, I use glm within a function testing for the appearence of the coexistence of (minor allels in a subset of) snps. And then I extract the Pr(>|z|)-value for the interaction. Principally it works but sometimes the function stops because this "value for the interaction" is NA. For instance, t

[R] retrieve data from summary output

2013-07-08 Thread Hermann Norpois
Hello, how can I retrieve electively data from a summary file, for instance I would like to get the Pr of Coefficients Thanks > summary (plasma_glm_1) Call: glm(formula = ESR ~ fibrinogen, family = binomial(), data = plasma) Deviance Residuals: Min 1Q Median 3Q Max -0.9298

[R] combination of columns in a matrix

2013-06-14 Thread Hermann Norpois
Hello, I have a matrix m and I want to know how often does 1 (or !0) simultanously appear in A and REF, B and REF, C and REF. So actually I wish to automate following expression: > length (which (m[,1]!=0&m[,4]!=0)) [1] 2 > length (which (m[,2]!=0&m[,4]!=0)) [1] 1 Thanks Hermann > m A B C

[R] image and color gradient

2013-05-17 Thread Hermann Norpois
Hello, I have a nice function that makes an image of an matrix e.g.: qt[1:3,1:3] rs655246 rs943795 rs955612 rs655246 NA NA NA rs943795 9.610070e-04 NA NA rs955612 5.555616e-05 7.915982e-07 NA myimage <- function(x, cex.axis = 0.7,

[R] convert a data.frame to matrix

2013-05-16 Thread Hermann Norpois
Hello, I fail to tranfer data from a dataframe to a matrix. jam is from a dataframe (and belongs still to the class dataframe) and should look like m (see below). > jam vec1 vec3 d1 d2 1 172 173 223 356 > dput (jam) structure(list(vec1 = 172L, vec3 = 173L, d1 = 223L, d2 = 356L), .Names = c

Re: [R] matrix - pairwise comparison of columns

2013-05-16 Thread Hermann Norpois
-as(mat1,"sparseMatrix") > #or > > mat2<-Matrix(mat1,sparse=TRUE) > 3 x 3 sparse Matrix of class "dtCMatrix" > #rs1 rs2 rs3 > #rs1 . . . > #rs2 1 . . > #rs3 2 1 . > > > > > A.K. > > > > - Original Messag

[R] matrix - pairwise comparison of columns

2013-05-15 Thread Hermann Norpois
Hello, I would like to do something with a matrix: 1) The columns should be compared pairwise. 2) And the result should be a matrix. I try to illustrate the problem with a testset. > m rs1 rs2 rs3 [1,] 1 1 1 [2,] 0 1 0 [3,] 2 0 1 > dput (m) structure(c(1, 0, 2, 1, 1, 0, 1,

[R] From a vector with characters to binary information

2013-03-30 Thread Hermann Norpois
Hello, I would like to transform a character vector into a "binary" vector ("keine" and " " become 0 and the rest 1). > dput (scm) c("keine", " ", "keine", "Erstgradverw.", "Mutter", "Erstgradverw.", "Erstgradverw.", "keine", " ", "Vater", "Erstgradverw.", "keine", "keine", "keine", "keine", " ",

[R] make a list with names with s/lapply

2013-02-19 Thread Hermann Norpois
Hello, I open some files in a directory and get a list. open.list <- sapply (namen, function (x) {file <- list.files (ddir, pattern=x, full.names=TRUE) # namen is vector and each element detects a special file to open file <- read.table (file)

Re: [R] count appearence of zero in a vector

2013-01-03 Thread Hermann Norpois
Very simple. And great. Thanks. 2013/1/3 Sarah Goslee > sum(test == 0) > > On Thu, Jan 3, 2013 at 5:49 PM, Hermann Norpois > wrote: > > Hello, > > > > I wish to count how often zero (0) appears in the vector test. > > > > test > > [1] 1 1 1 1 1

[R] count appearence of zero in a vector

2013-01-03 Thread Hermann Norpois
Hello, I wish to count how often zero (0) appears in the vector test. test [1] 1 1 1 1 1 1 2 1 1 1 0 2 0 1 1 0 0 0 1 1 1 0 1 2 1 1 1 1 1 1 I think of something like ... > sapply (test, function (x) if (x==0 ... ... but actually I dont know how to carry on. Could anybody give me a hint? Tha

[R] fusion of overlapping intervals

2012-11-05 Thread Hermann Norpois
Hello, I have start and end coordinates from different experiments (DNase hypersensitivity data) and now I would like to combine overlapping intervals. For instance (see my test data below) (2) 30-52 and (3) 49-101 are combined to 30-101. But 49-101 and 70-103 would not be combined because they ar

[R] subset a defined row plus the aforegoing

2012-11-01 Thread Hermann Norpois
Hello, my data is sorted by start.ens (see below). And now I would like to extract all rows (so called* defined row*s) with type==Expression - subset (df, type==Expression) - and the aforegoing type==DNase HS (which is not necessarly row n-1 - assumung that the defined row is n). I dont know how t

[R] serial subtraction within a vector

2012-09-24 Thread Hermann Norpois
Hello, I have a vector (numeric) v-> c(a,b,c,d,e) and I want to create the vector n->c(b-a,c-b,d-c,e-d). How can I do that? Thank you Hermann [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailm

[R] qplot: plotting precipitation data

2012-09-15 Thread Hermann Norpois
t;chr8", "chr9", "chrX"), class = "factor"), start = c(5291000L, 10988025L, 11767950L, 11840900L, 12267450L, 12276675L), end = c(5291926L, 10988526L, 11768676L, 11841851L, 12268076L, 12277051L), peak = c(8L, 7L, 8L, 8L, 12L, 7L)), .Names = c("chrom"

[R] plot: x and y chromosomes are missing

2012-09-10 Thread Hermann Norpois
Hello, I have a list with gene names, fold changes (=expression level) and chromosomes. Names fold change chromosome hz 1.5 2 If I plot fold change versus chromosome (or vice versa): plot (ch, fc) I see only the chromosomes with numbers but not those with letter (x an

[R] Installing lumi and hdrcde

2012-09-05 Thread Hermann Norpois
not detected by > (.packages(all.available=TRUE)) if installed in the R library. Thanks Hermann Norpois This was my try to install the lumi package: > source ("http://bioconductur.org/biocLite.R";) Fehler in file(filenaReme, "r", encoding = encoding) : kann Verbindu

[R] problem with function

2012-07-17 Thread Hermann Norpois
rn fc or attr... in my function neither Then I can get access to newdata and on but not on fc or attr(mydata, 'fc'). Is there a possibility to use function and having access to attr AND newdata? Thanks Sincerely Hermann Norpois [[alternative HTML version deleted]] __