Question: Scatter plot for two data sets
0
gravatar for saj98
23 months ago by
saj98100
saj98100 wrote:

Hello every one

I have two CSV files from different RNA seq data, I like to do scatter plot to study the similarity between both experiments. I do not know how to plot two different variables from two different files. Do you have any suggestion or idea how to plot two different data sets? Thanks for help

rna-seq R • 1.3k views
ADD COMMENTlink written 23 months ago by saj98100
1

Hi, do the data have the same length? If you import the data with data1 = read.csv() and data2 = read.csv(), can't you then do:

plot(data1$variable1, data2$variable2)

? C.

ADD REPLYlink written 23 months ago by cristian220

Yes the data frame is similar, but the labels are different between the two files. The first experiment done on cells and the second experiment done on tissue. I did what you asked me so I got this error plot(G$AF.Cell, G1$AF.tissue) Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' and 'y' lengths differ

ADD REPLYlink written 23 months ago by saj98100
1

So you know where the error is then? Could you post the code you've used to fix the problem, please

ADD REPLYlink written 23 months ago by russhh4.4k

Sure, I am pasting it

 G <- read.csv(file.choose(), header = TRUE, sep = ",")
> head(G)
    gene  AD.tissue
1  ACA64 132.412000
2 Acaa1a   6.530200
3  Acaa2  12.099600
4  Acaca   5.238780
5  Acacb   0.799083
6 Acad10   5.033970
> G1 <- read.csv(file.choose(), header = TRUE, sep = ",")
> head(G1)
  geneNames      AF.Cell
1     ACA64 4.562277e+02
2     Acaca 1.676200e+01
3     Acaca 8.086103e+01
4     Acacb 3.741280e-02
5     Acacb 5.041820e-02
6     Acacb 5.890000e-07
> plot(G$AD.tissue, G1$AF.Cell)
Error in xy.coords(x, y, xlabel, ylabel, log) : 
  'x' and 'y' lengths differ
ADD REPLYlink modified 23 months ago by WouterDeCoster39k • written 23 months ago by saj98100

Sorry, could you post it in your initial question and format it. Please indicate which of those columns could be used to match rows in one dataset with rows in the other, and I might be able to help you

ADD REPLYlink written 23 months ago by russhh4.4k
1

You need a gene-level average before you can compare the results in one dataset with the results in the other, which is unfortunate, since if you had at most one entry for each gene, it would be a simple case of merge with by.x="gene", by.y="geneNames" then plot.

ADD REPLYlink written 23 months ago by russhh4.4k

I added markup to your post for increased readability. You can do this by selecting the text and clicking the 101010 button. When you compose or edit a post that button is in your toolbar, see image below:

101010 Button

ADD REPLYlink written 23 months ago by WouterDeCoster39k

I think ther's a swirl tutorial on base R graphics in the R Programming course see here

ADD REPLYlink written 23 months ago by russhh4.4k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1019 users visited in the last hour