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 8164521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:20:08+00:00 2026-06-06T19:20:08+00:00

I`m working on a script to create csv files for an analysis. When running

  • 0

I`m working on a script to create csv files for an analysis. When running the script it gives 1 csv file for the OPA 5701 and 1 for the 6561. This is the only difference between the 2 parts of the script.

##Samplesheet for GS0005701
rows<-unique(samples$Sample_Name)
samplesheet<-rows
opa.panels<-sort(unique(samples$Pool_ID))
for ( i in 1:length(opa.panels)){
  samps<-samples[samples$Pool_ID == opa.panels[i],]
  idx<-match(samps$Sample_Name,rows)
  samplesheet<-cbind(samplesheet,samps$Sentrix_ID[idx],samps$Sentrix_Position[idx])
}
colnames(samplesheet)[2:(length(opa.panels)*2+1)]<-c("SentrixBarcode_A","SentrixPosition_A","SentrixBarcode_B","SentrixPosition_B","SentrixBarcode_C","SentrixPosition_C","SentrixBarcode_D","SentrixPosition_D")[1:(length(opa.panels)*2)]
colnames(samplesheet)[1]<-"Sample_Name"
idx<-match(rows,samples$Sample_Name)
samplesheet<-cbind(samplesheet,samples[idx,c("Sample_Group","NorTum","Sample")])
ss_header<-c("[Header]","Investigator Name,Sander","Project Name,HNPCC_NA_MYH","Experiment Name,OPA1+2+3+4","Date,5062012","[Manifests]")
for (i in 1:length(opa.panels)) ss_header<-c(ss_header,paste(LETTERS[i],opa.panels[i],sep=","))
ss_header<-c(ss_header,"[Data]")
writeLines(ss_header,"Samplesheet5701.csv")
write.table(samplesheet,file="Samplesheet5701.csv",sep=",",row.names=FALSE,quote=FALSE,append=TRUE,na="")

##Samplesheet for GS0006561-OPA
rows2<-unique(samples2$Sample_Name)
samplesheet2<-rows2
opa.panels2<-sort(unique(samples2$Pool_ID))
for ( j in 1:length(opa.panels2)){
  samps2<-samples2[samples2$Pool_ID == opa.panels2[j],]
  idx2<-match(samps2$Sample_Name,rows2)
  samplesheet2<-cbind(samplesheet2,samps2$Sentrix_ID[idx2],samps2$Sentrix_Position[idx2])
}
colnames(samplesheet2)[2:(length(opa.panels)*2+1)]<-c("SentrixBarcode_A","SentrixPosition_A","SentrixBarcode_B","SentrixPosition_B","SentrixBarcode_C","SentrixPosition_C","SentrixBarcode_D","SentrixPosition_D")[1:(length(opa.panels)*2)]
colnames(samplesheet2)[1]<-"Sample_Name"
idx2<-match(rows2,samples2$Sample_Name)
samplesheet2<-cbind(samplesheet2,samples2[idx2,c("Sample_Group","NorTum","Sample")])
ss_header<-c("[Header]","Investigator Name,Sander","Project Name,HNPCC_NA_MYH","Experiment Name,OPA1+2+3+4","Date,5062012","[Manifests]")
for (j in 1:length(opa.panels2)) ss_header<-c(ss_header,paste(LETTERS[j],opa.panels2[j],sep=","))
ss_header<-c(ss_header,"[Data]")
writeLines(ss_header,"samplesheet6561.csv")
write.table(samplesheet2,file="Samplesheet6561.csv",sep=",",row.names=FALSE,quote=FALSE,append=TRUE,na="")

The ## Samplesheet GS0005701 part creates an data.frame. While the ##Samplesheet GS0006561 creates an matrix. With the same code and the same input data.

The input data looks like this:

Sample Data

For copy paste:

    Sample  Sample_Name Sample_Group    NorTum  Sentrix_ID  Sentrix_Position    Pool_ID Folderdate
1   00-04193    00-04193N   HNPCC_UV    N   1495421 R007_C012   GS0006564-OPA   Exp060410
2   00-04193    00-04193N   HNPCC_UV    N   1495447 R007_C012   GS0006562-OPA   Exp060410
3   00-04193    00-04193N   HNPCC_UV    N   1495447 R007_C006   GS0006561-OPA   Exp060410
4   00-04193    00-04193N   HNPCC_UV    N   1495421 R007_C006   GS0006563-OPA   Exp060410
5   00-04193    00-04193N   HNPCC_UV    N   1460498 R007_C005   GS0006561-OPA   Exp060516
6   00-04193    00-04193N   HNPCC_UV    N   1460498 R007_C012   GS0006564-OPA   Exp060516

I know this is a difficult to answer question, but i`m hoping someone can give me a hint about how its possible that 1 code creates an data.frame and the other an matrix.

Very much thanks in advance!

  • 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-06-06T19:20:10+00:00Added an answer on June 6, 2026 at 7:20 pm

    The correct answer to this question was a swap in the index part.

    idx<-match(samps$Sample_Name,rows)
    

    was changed to:

    idx<-match(rows,samps$Sample_Code) 
    

    So that the length of rows is the same as the length of Sample_Code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used this script to create a jQuery accordion. Check out the working jsFiddle
I am working on a script to create files basically replica of some tables
I'm working on a Python script that needs to create about 50 distinct temporary
I'm working on a few scripts to create txt files, rsync a few files
I have a working script from someone, there in is this line: this.event =
I have working registration script the only problem is that i do not know
So, i'm working on a progress bar for a CSV processing script. dnc_scrubber.php goes
I have a working script like this: jQuery(document).ready(function(){ $('.video-thumb img').bind('mouseover',function(){ var new = $(this).attr('src').replace(/default.jpg/,'1.jpg');
To piggyback onto this question, PowerShell script to delete files from list and output
Update: I wrote a working script that finishes this job in a reasonable length

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.