Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4538298
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:47:35+00:00 2026-05-21T14:47:35+00:00

Input file is Mydata <- read.table(con <- textConnection(‘ gene treatment1 treatment2 treatment3 aaa 1

  • 0

Input file is

Mydata <- read.table(con <- textConnection('
gene treatment1 treatment2 treatment3
aaa 1 0 1
bbb 1 1 1
ccc 0 0 0
eee 0 1 0
'), header=TRUE)
close(con)

Mydata is

  gene treatment1 treatment2 treatment3
1  aaa          1          0          1
2  bbb          1          1          1
3  ccc          0          0          0
4  eee          0          1          0

In order to built cluster, I have done

d <- dist(mydata, method = "euclidean")
fit <- hclust(d, method="ward") 
plot(fit)

I got the cluster based on “euclidean” distance.

In my previous message in stackoverflow
How to use R to compute Tanimoto/Jacquard Score as distance matrix

I found I can also calculate tanimoto-jacquard distance matrix with R. Could you mind to teach me how to incorporate tanimoto-jacquard with the previous steps to get a cluster based on distance matrix calculated by tanimoto-jacquard distance instead of euclidean? Thanks a lot.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T14:47:36+00:00Added an answer on May 21, 2026 at 2:47 pm

    What is it you don’t understand? ?vegdist tells us that it returns an object of class "dist" so you can just remove the dist(....) line and replace it with one calling vegdist(....). For example:

    require(vegan)
    d <- vegdist(Mydata[, -1], method = "jaccard")
    fit <- hclust(d, method="ward") 
    plot(fit)
    

    You need to drop the first column (and should have done in the Euclidean version you showed in your Q) as this is not data that should be used to form the dissimilarity matrix.

    That will generate a warning:

    Warning message:
    In vegdist(Mydata[, -1], method = "jaccard") :
      you have empty rows: their dissimilarities may be meaningless in method jaccard
    

    because row 3 contains no information to form the jaccard distance between it and the other samples. You might want to consider if the jaccard is most appropriate in such cases.

    The OP now wants the gene labels as row names. The easiest option is to tell R this when reading the data in, using the row.names argument to read.table():

    mydata2 <- read.table(con <- textConnection("gene treatment1 treatment2 treatment3
    aaa 1 0 1
    bbb 1 1 1
    ccc 0 0 0
    eee 0 1 0
    "), header = TRUE, row.names = 1)
    close(con)
    

    giving:

    > mydata2
        treatment1 treatment2 treatment3
    aaa          1          0          1
    bbb          1          1          1
    ccc          0          0          0
    eee          0          1          0
    

    Or if the data are already in R and it is a pain to reload and redo previous computations, just assign the gene column to the row names and remove the gene column (using the original mydata):

    rownames(mydata) <- mydata$gene
    mydata <- mydata[, -1]
    

    giving:

    > mydata
        treatment1 treatment2 treatment3
    aaa          1          0          1
    bbb          1          1          1
    ccc          0          0          0
    eee          0          1          0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My input file's contents are: welcome welcome1 welcome2 My script is: for groupline in
My input file is a large txt file with concatenated texts I got from
If I have this input file in xml: <root> <node id=N1> <fruit id=1> <orange
Say I have an input file, and a target directory. How do I determine
I have an XML input file and I'm trying to output the result of
I have an input file that I want to sort based on timestamp which
My raw input file text file contains a string: Caf&eacute (Should be Café) The
If I have an input file like: US, P1, AgriZone, H, 1000, 1200, 1101,
I am styling an Input File type using only CSS, and it works on
Given input file z b a f g a b ... I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.