Displaying 20 results from an estimated 32 matches for "distfun".
2004 Sep 07
3
heatmap help
Dear R wizards,
Hopeful someone can help me with what I believe is a pretty simple task. I
pretty new to R so some (much) of the obvious escapes me. How do I get a
distance matrix into heatmap? What do I tell distfun if what I'm trying to
map is already an ordered distance matrix? I tried >heatmap(x,
distfun=as.dist(x)) where x is the distance matrix but R gave me an error.
Thanks in advance for any help.
Paul Lepp
`-:-. ,-;"`-:-. ,-;"`-:-. ,-;"`-:-. ,-;"`-:-. ,-;"`...
2010 Jan 12
1
Strange behavior when trying to piggyback off of "fitdistr"
...ramming language book (perhaps I should invest in it) and the online help wasn't that helpful to me, so I would very much appreciate any responses y'all may have.
Thank you very much,
--Avi
#####################################################
Code (Unfinished)
MSEFit <- function (x, distfun, start, ...)
{
require (MASS); require (actuar);
Call <- match.call(expand.dots = TRUE)
if (missing(start))
start <- NULL
dots <- names(list(...))
if (missing(x) || length(x) == 0L || mode(x) != "numeric")
stop("'x' must be a non-...
2004 Dec 15
1
hclust and heatmap - slightly different dendrograms?
...was reversed in the
two functions (but all individual columns were grouped correctly).
Looking through the code for heatmap as a most definite nonexpert, it
seems to me that hclust is also invoked by heatmap.
> heatmap
function (x, Rowv = NULL, Colv = if (symm) "Rowv" else NULL,
distfun = dist, hclustfun = hclust, add.expr, symm = FALSE,
...
hcr <- hclustfun(distfun(x))
ddr <- as.dendrogram(hcr)
....
hcc <- hclustfun(distfun(if (symm)
x
else t(x)))
ddc <- as.dendrogram(hcc)
I understand it is possible to add Rowv...
2012 Feb 28
1
Unexpected behaviour for RowSideColors in function heatmap
...When calling the function in symmetric mode, the ColSideColors are plotted correctly, but RowSideColors appear in reverse order. This code (modified from the example on the help page) demonstrates the problem:
cU <- cor(USJudgeRatings)
sideCols <- rainbow(ncol(cU))
heatmap(cU, symm = TRUE, distfun = function(c) as.dist(1 - c),
ColSideColors=sideCols, RowSideColors=sideCols)
Reversing the RowSideColors argument does not solve the problem:
heatmap(cU, symm = TRUE, distfun = function(c) as.dist(1 - c),
ColSideColors=sideCols, RowSideColors=rev(sideCols))
I had a look at the the...
2013 Oct 21
3
Error in heatmap
Hi,
Could you please help?
Heatmap doesn't work with:
> heatmap(as.matrix(SPIV2),na.rm = T)
Error in hclustfun(distfun(x)) :
NA/NaN/Inf in foreign function call (arg 11)
There are no 0 data rows or column
Thanks a lot
Regards
---------------------------------------
David
2013 Jun 22
1
metaMDS Error, Nan similar or negative values
...MDS(
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 <- metaMD...
2007 Oct 08
2
heatmap
Hi,
I am having troubles with heatmap(). I have a matrix containing pairwise
distance values and I want to plot this matrix with heatmap. I wonder
now what distfun is for. Is a distance matrix computed from my initial
matrix again and then plotted?
cheers,
andreas
2007 Jul 19
3
Error: evaluation nested too deeply when doing heatmap with binary distfunction
Hi netters,
I have a matrix X of the size (1000,100). The values are from -3 to +3.
When I tried
heatmap(X,
distfun=function(c),dist(c,method="bin"),hclustfun=function(m),hclust(m,method="average"))
I got the error message:
Error: evaluation nested too deeply: infinite recursion /
options(expressions=)?
However, if I used default parameters for distfunction:
heatmap(X, hclustfun=function...
2008 Jan 11
1
Adding weights to ecdf
...;stepfun", class(rval))
attr(rval, "call") <- sys.call()
rval
}
and as a particular example, to see how the E.C.D.F. behaves
in the length--biased framework consider running the following
function with different values for n
lengthBiasExample <- function(n=100)
{
distFun <- function(x) pgamma(x,shape=1,rate=1)
##lenght biased version of a gamma(shape=1,rate=1)
x <- rgamma(n,shape=2,rate=1)
par(ask=T)
Fx <- ecdf(x)
newFx <- newEcdf(x,1/x)
plot(Fx,pch="+")
curve(distFun,from=0,to=10,add=T,col="red")
plot(newFx,pch="+&q...
2008 Nov 14
0
Error in optim when i call it from a function
...ot;)
n <- length(x)
if (is.character(densfun)) {
distname <- tolower(densfun)
densfun <- switch(distname,exponential = dexp,gamma = dgamma,
"log-normal" = dlnorm,
lognormal = dlnorm, weibull = dweibull, pareto = dpareto,
NULL)
distfun <- switch(distname,exponential = pexp,gamma = pgamma,
"log-normal" = plnorm,
lognormal = plnorm, weibull = pweibull, pareto = ppareto,
NULL)
if (is.null(densfun))
stop("unsupported distribution")
if (distname %in% c("l...
2014 Oct 15
2
Test K-S con distribuciones LogNormales
...ucket <- 10 # numero de buckets
>>
>> # Generamos la muestra de tamaño n
>> sample <- sort(rlnorm(n, meanlog = mean, sdlog = sd))
>> # Función de distribución
>> df <- plnorm(sample, meanlog = mean, sdlog = sd)
>> lognorm1 <- data.frame(sample=sample, distfun=df)
>> # Gráfica de la función de distribución sin bucketizar
>> plot(lognorm1, type = "l", col = "red")
>>
>> # Bucketización - Muestra bucketizada
>> library(plyr)
>> dt <- data.frame(sample=sample, bucket=rep(1:nbucket, each = n/nbucket)...
2003 Sep 24
1
heatmap and hclust
Hi all,
The function heatmap uses the functions dist and hclust with default
parameters.
How to change these parameters? For example, i want to use the ward
criterion for hierarchical
clustering with binary distance.
Best regards,
Olivier.
2007 Jan 19
1
Error in heatmap()
Hi,
I run into following error when using heatmap() for data matrix "xx".
Any help is appreciated? "xx" contains many "NA"s.
> hv <- heatmap(data.matrix(xx))
Error in hclustfun(distfun(if (symm) x else t(x))) :
NA/NaN/Inf in foreign function call (arg 11)
Thanks a lot.
Yuhong
*********************************************************
THIS ELECTRONIC MAIL MESSAGE AND ANY ATTACHMENT IS
CONFIDENTIAL AND MAY CONTAIN LEGALLY PRIVILEGED
INFORMATION INTENDED ONLY F...
2009 Jan 09
1
Calculating p-values from your own distribution as an array
Hi -
If I have a hypothetical distribution as an array
distribution<-c(0,1,2,3,4,5,6,7,8,9)
and I want to find the probability there is a value smaller than a new
value.
new_value<-4
(such that I'd get this type of output)
new_value p-value
4 0.5
3.4 0.4
3 0.4
0 0.1
-1 0.0
Thanks for the help, I bet this is really easy... :/
Stephen
--
The Wellcome Trust Sanger Institute is
2011 Jul 24
0
setting distance matrix and clustering methods in heatmap.2
heatmap.2 defaults to dist for calculating the distance matrix and hclust for
clustering.
Does anyone now how I can set dist to use the euclidean method and hclust to
use the centroid method?
I provided a compilable sample code bellow.
I tried: distfun = dist(method = "euclidean"),
but that doesn't work. Any ideas?
library("gplots")
library("RColorBrewer")
test <- matrix(c(79,38.6,30.2,10.8,22,
81,37.7,28.4,9.7,19.9,
82,36.2,26.8,9.8,20.9,
74,29.9,17.2,6.1,13.9,
81,37.4,20.5,6.7,14.6),ncol=5,byrow=TRUE)
col...
2011 Jul 27
0
Inversions in hierarchical clustering were they shouldn't be
...est) <- c("Exp1","Exp2","Exp3","Exp4")
rownames(test) <- c("Gene1","Gene2","Gene3", "Gene4")
test <- as.table(test)
mat = data.matrix(test)
heatmap.2(mat, dendrogram="row", Rowv=TRUE,
Colv=FALSE, distfun = function(x) dist(x,method = ''maximum''),
hclustfun = function(x) hclust(x,method = ''centroid''),
xlab = NULL, ylab = NULL, key=TRUE,
keysize=1, trace="none", density.info=c("none"),
margins=c(6, 12), col=bluered
)
This gives a...
2013 Dec 07
1
How to perform clustering without removing rows where NA is present in R
...quot;)
# Arbitrarily assigning NA to some elements
mtcars[2,2] <- "NA"
mtcars[6,7] <- "NA"
mydata <- mtcars
hclustfunc <- function(x) hclust(x, method="complete")
# Initially I wanted to use this but it didn't take NA
#distfunc <- function(x) dist(x,method="euclidean")
# Try using daisy GOWER function
# which suppose to work with NA value
distfunc <- function(x) daisy(x,metric="gower")
d <- distfunc(mydata)
fit <- hclustfunc(d)
# Perform clustering heatmap
he...
2013 Sep 06
1
Fwd: calculating dissimilarity index of islands (vegan and betapart)
...erates
the dissimilarity index for island.
(Does it compare species presence/absence between a pair of island?
Should the two islands be specifically located or close to each other?)
Thank you
Elaine
Code
# NMDS
library(MASS)
library(vegan)
island.NMDS <- metaMDS(island,k=2, distfun = betadiver, distance =
"sim",trymax=100,zerodist="add")
plot(island.NMDS, type = "n")
#Simpson Dissimilarity Index
library(betapart)
island.dist<-beta.pair(island, index.family="sor")
class(island.dist)
[[alternative HTML version del...
2008 May 15
1
metaMDS using Dissimilarity matrix
Hello R-user community!
I am running R 2.7.0 on a Power Book (Tiger). (I am still R and
statistics beginner)
Presently I try to run the function metaMDS (vegan) using an existing
dissimilarity-matrix.
As I would like to start with this matrix I thought I could just give
the matrix using the x= -argument
Test<-metaMDS(x=Dist.Gower)
Fehler in inherits(comm, "dist") :
2010 Sep 18
1
Drawing Heatmap using gplots
Hi,
I am using heatmap.2 of gplots to make heatmaps of my the attached file. I
am giving my code for the same ..
library(gplots)
x=read.table("1.txt", header=TRUE)
mat=data.matrix(x)
heatmap.2(mat, col=greenred(75),
Rowv=TRUE,
Colv=TRUE,
distfun = dist,
hclustfun = hclust,
dendrogram = c("both"),
scale = c("row"),
na.rm=TRUE,
trace="none",
sepwidth=c(0.05,0.05),
margins = c(5, 10),
xlab = "EXPRESSIONS", ylab = "GENES",
labRow = NULL,
labCol = NULL,
key=TRUE,
keysize=1,
density.info=c("...